I am trying to get revision feed for an existing document in Google Docs (actually I just need revision count). I use the code below and get a GDataRequestException. The inner exception is 404 while the response string is (document id is truncated):
<errors xmlns='http://schemas.google.com/g/2005'>
<error>
<domain>GData</domain>
<code>ResourceNotFoundException</code>
<internalReason>Invalid document id: file:0BxwzFL2fD0</internalReason>
</error>
</errors>
And here is the code:
var documentsService = new DocumentsService("myappname");
documentsService.SetAuthenticationToken(token);
var uri = string.Format("https://docs.google.com/feeds/default/private/full/{0}/revisions", Uri.EscapeDataString(resourceId));
var query = new DocumentsListQuery(uri);
var feed = documentsService.Query(query);
It looks like the resourceId you are using is invalid.
Instead of constructing the uri manually, you should use the RevisionDocument property of the DocumentEntry instance you want to retrieve the revisions for:
var uri = entry.RevisionDocument;
var documentsRequest = new DocumentsRequest();
// ... do any authentication here..
var revisions = documentsRequest.Get<Google.Documents.Document>(entry.RevisionDocument).Entries;
Related
I am using C# DocuSign SDK. I am simply trying to retrieve Envelopes, so using EnvelopesApi.ListStatusAsync. Like this:
EnvelopesApi envelopeApi = new EnvelopesApi(ApiClient.Configuration);
var options = new ListStatusOptions();
var date = DateTime.Now.AddDays(-30);
options.fromDate = date.ToString("yyyy/MM/dd");
var envelopesList = envelopeApi.ListStatusAsync(AccountId, null, options);
Response:
Error calling ListStatus:
{
"errorCode": "INVALID_REQUEST_BODY",
"message": "The request body is missing or improperly formatted."
}
Fiddler shows a 400. I can see Access Token is included in the request (Bearer Authorization Header), so no issues there. Fiddler shows PUT request:
https://demo.docusign.net/restapi/v2.1/accounts/[Account_ID_Guid]/envelopes/status?from_date=2019%2f12%2f14
Basically, this is code retrieved from: https://github.com/docusign/qs-csharp. Only difference is using ListStatusAsync instead of ListStatus. Am I missing something related to Body?
Your code doesn't quite match what the QuickStart example does. In the QS, the method used is ListStatusChanges, not ListStatus.
Try this to get a list of envelopes from the past 30 days:
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient.Configuration);
var options = new EnvelopesApi.ListStatusChangesOptions();
var date = DateTime.Now.AddDays(-30);
options.fromDate = date.ToString("yyyy/MM/dd");
var envelopesList = envelopesApi.ListStatusChanges(accountId, options);
var envelopesListFromAsync = envelopesApi.ListStatusChangesAsync(accountId, options);
Is it possible to append a segment to a MS Graph GraphServiceClient Request and fetch that resource?
The scenario:
I want to get the root site of a group (more specifically its weburl property)
https://graph.microsoft.com/v1.0/groups/{group-id}/sites/root
but it is not possible to append the /root segment with the QueryBuilder and enumerating sites is not allowed and throws an exception
var task = graphClient.Groups[group.Id].Sites.Request().GetAsync() // exception
I can get the string for the request
var url = graphClient.Groups[group.Id].Sites.Request().AppendSegmentToRequestUrl("root")
But then I would need a method to which I can supply a full Graph Url, for example:
graphClient.MakeRequest(url).GetAsync()
I know I could use the HttpClient Class but that would introduce a different pattern to fetch Graph Resources and I would like to avoid that.
Edit - Solution
Seems as if you have to play with the RequestBuilders that are available under the Microsoft.Graph namespace until you find one that matches the type of your request, all the others return null.
var requestBuilder = client.Groups["guid-of-group"].Sites;
var url = requestBuilder.AppendSegmentToRequestUrl("root");
GroupRequestBuilder builder = new GroupRequestBuilder(url, client);
var result = await builder.Request().GetAsync();
Perharps you could try something like this and pass in the graphServiceClient and created url to a new instance of a request builder.
// create the url from the builders
var requestBuilder = graphClient.Groups["groupId"].Sites;
var url = request.AppendSegmentToRequestUrl("root");
// we have to create a new builder as the url property cannot be set/modified publicly
GroupSitesCollectionRequestBuilder groupSitesCollectionRequestBuilder = new GroupSitesCollectionRequestBuilder(url, graphClient);
// Make the call
var result = await groupSitesCollectionRequestBuilder.Request().GetAsync();
Basically, I have a custom object inheriting from place. I am creating a c# tool for creating the objects using the Facebook Sharp c# SDK located here I am using an app access token when making these calls.
I've tried various approaches and variation within:
Here is a sample call that yeilds:
(OAuthException - #100) (#100) The parameter object is required
_api.AccessToken = GetExtendedToken().Token;
var postdata = new Dictionary<string, object>
{
//{"fb:app_id", "appId"},
//{"type", "myapp:myobject"},
{"url", resort.Url},
{"title", resort.Name },
{"image", resort.Image},
{"video", resort.Video},
{"description", resort.Description},
{"place:location:latitude", lat},
{"place:location:longitude", long}
};
var response = _api.Post("/app/objects/myapp:myobject", postdata);
if I uncomment the type parameter I get:
(OAuthException - #2500) Cannot specify type in both the path and query parameter
If I add the type back in, and remove the type from the path, I get
a response of true but this should be something like id:
23049820398092384
If I remove the place objects, or if I remove place and type, or if
I remove place but use the type and change the get path, I still get
errors.
refactored a bit. In this scenario I needed to assign the postdata information to an object as such below. also needed to stop using facebooksharp, their api does weird stuff to the request.
var obj = new
{
app_id = appId,
type = app_name:object_type",
url = Url,
title = Name,
image = Image,
video = Video,
description = Description
};
var vars = new NameValueCollection {{"object", JsonConvert.SerializeObject(obj)}, {"format", "json"}, {"access_token", AppToken}};
var url = "https://graph.facebook.com/app/objects/"+ _appName + object_type;
return HttpTools.Post(url, vars);
I would like to execute a query on google images to fetch images using htmlagilitypack in c#.
For this I used an xpath request to the image
//*[#id="rg_s"]/div[1]/a/img
But it fails to fetch the image that way. What could be the correct way of doing this?
you can try this too : Here its possible to get the links of images by following
var links = HtmlDocument.DocumentNode.SelectNodes("//a").Where(a => a.InnerHtml.Contains("<img")).Select(b => b.Attributes["href"].Value).ToList();
foreach(var link in links)
{
// you can save the link or do your process here
}
Google keeps found images in div tags with class rg_di. Here is a query to get all links to images:
var links = hdoc.DocumentNode.SelectNodes(#"//div[#class='rg_di']/a")
.Select(a => a.GetAttributeValue("href", ""));
Searching google programmatically outside of their API's is against the TOS. Consider Google Custom Search or Bing Search API, both of which have established JSON and SOAP interfaces.
Both are free for a couple thousand queries per month and comply with the service's TOS.
Edit: Examples of using Bing API with C# below:
const string bingKey = "[your key here]";
var bing = new BingSearchContainer(new Uri("https://api.datamarket.azure.com/Bing/Search/"))
{
Credentials = new NetworkCredential(bingKey, bingKey)
};
var query = bing.Web("Jon Gallant blog", null, null, null, null, null, null, null);
var results = query.Execute();
foreach(var result in results)
{
Console.WriteLine(result.Url);
}
Console.ReadKey();
Google custom search API:
string apiKey = "Your api key";
string cx = "Your custom search engine id";
string query = "Your query";
var svc = new Google.Apis.Customsearch.v1.CustomsearchService(new BaseClientService.Initializer { ApiKey = apiKey });
var listRequest = svc.Cse.List(query);
listRequest.Cx = cx;
var search = listRequest.Fetch();
foreach (var result in search.Items)
{
Response.Output.WriteLine("Title: {0}", result.Title);
Response.Output.WriteLine("Link: {0}", result.Link);
}
Somebody know what I'm doing wrong?
var service = new Service("lh2", "exampleCo-exampleApp-1");
service.setUserCredentials("myuser", "mypass");
var myPhoto = new PhotoEntry
{
Title = new AtomTextConstruct(
AtomTextConstructElementType.Title,
"Puppies FTW")
};
var myMedia = new MediaFileSource(#"C:\puppies.jpg", "image/jpeg");
myPhoto.MediaSource = myMedia;
var u="https://picasaweb.google.com/data/feed/api/user/default/albumid/default";
var returnedPhoto = service.Insert(new Uri(u), myPhoto);
Actually is returning bad request error (400) with the following response string: Photo data or source id must be included
It was returning error because the Uri was wrong:
I must use:
var u="https://picasaweb.google.com/data/media/api/user/default/albumid/default";
instead:
var u="https://picasaweb.google.com/data/feed/api/user/default/albumid/default";