What api.onedrive.com endpoints can be used for reading, deleting and creating comments of documents stored in OneDrive?
var docId = "C382F44F3E2D3362!392363";
using (var http = new HttpClient()) {
var json = await http.GetStringAsync($"https://api.onedrive.com/v1.0/???{docId}???/comments");
var comments = JObject.Parse(json);
...
}
I need to rewrite an app which use Live SDK to manipulate OneDrive comments. Live SDK is deprecated now. I need an API which is currently supported.
OneDrive is a cloud storage system, it doesn't support directly editing the files stored on it
Related
I try to use Graph API SDK to query a file in a SharePoint site
var site = await graphClient.Sites["myDomain"]
.SiteWithPath("relativePath").Request()
.GetAsync().ConfigureAwait(false);
var drive = await graphClient.Sites["myDomain]
.SiteWithPath("relativePath").Lists["mylib"].Drive
.Request().GetAsync().ConfigureAwait(false);
var file = await graphClient.Sites[site.Id]
.Drives[drive.Id].Root.ItemWithPath("/folder1").Children["myfile.txt"]
.Request().GetAsync().ConfigureAwait(false);
This is working and I get the file.
I try to combine the three steps into one,
var file = await graphClient.Sites["myDomain"]
.SiteWithPath("relativePath").Lists["mylib"].Drive
.Root.ItemWithPath("/folder1").Children["myfile.txt"]
.Request().GetAsync().ConfigureAwait(false);
But it gives Bad Request error. What's wrong? What is the best way to do this?
The navigation you are using is not accepted by Graph.
As per the get files docs, you need the site-id.
# Valid
GET /sites/mydomain.sharepoint.com:/relativePath/lists/mylib/drive
# Invalid addition to above url
GET /sites/mydomain.sharepoint.com:/relativePath/lists/mylib/drive/root:/myfile.txt:
If you don't have the site id, you can expand the list relationship in the get list drive call and use the site-id to request for the file. This will be two requests instead.
var drive = await graphServiceClient
.Sites["mydomain.sharepoint.com"]
.SiteWithPath(relativePath)
.Lists["mylib"]
.Drive
.Request()
.Expand("list")
.GetAsync()
.ConfigureAwait(false);
var file = await graphServiceClient
.Sites[drive.List.ParentReference.SiteId]
.Drives[drive.Id]
.Root.ItemWithPath("/Folder 1")
.Children["myfile.txt"]
.Request().GetAsync().ConfigureAwait(false);
I use the MS Graph API to upload data to OneDrive.
I have deleted all data on OneDrive, but when I use the :
var search = await graphClient.Users[user.Id].Drive.Root
.Search("")
.Request()
.GetAsync();
foreach (var item in search)
{
Console.WriteLine(item.Name);
}
I get data displayed even though my OneDrive is empty, why ?
I use:
.Net 4.7.2,
Visual Studio
The solution is:
If I use this code:
var search = await graphClient.Users[user.Id].Drive.Root
.Search("")
.Request()
.GetAsync();
He's searching through the index.
Data can also be displayed there although it is no longer available.
Therefore, data that is no longer available on OneDrive is also displayed.
Do not use the search function.
Is there a way to fetch the list of tags created for a team project, basically we need information such as creation date, created by user etc.
Can we fetch these information using TFS RestApi? If so it would be helpful if code snippets are provided.
There isn't the information of created by user, you can check it in dbo.tbl_TagDefinition table of collection database.
To fetch the list of Tags, you can refer to Giulio’s answer, for example:
[collection URL]/_apis/tagging/scopes/[Team Project ID]/tags?api-version=1.0
To get Team Project ID, you can call this REST API:
[Collection URL]/_apis/projects?api-version=1.0
Simple code for C#:
String MyURI = "[collection URL]/_apis/tagging/scopes/f593de42-d419-4e07-afc7-1f334077c212/tags?api-version=1.0";
WebRequest WReq = WebRequest.Create(MyURI);
WReq.Credentials =
new NetworkCredential("[user name]", "[password]", "[domain"");
WebResponse response = WReq.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
There is a REST API to manage Tags, but there is not auditing information as per your request.
If you want to learn how to call a REST API there is plenty of sources, starting from the Get started page.
I am trying to port a application developed using version 2 API of google youtube to version 3.
How can I get title of a playlist using version 3 API? We could get the title of playlist using version 2. However, title I get when I query playlist's snippet is different from what it is shown on the youtube website.
Is there any difference in Version 3?
I am using .NET API library from Google. if this helps.
Can anyone please help?
EDITED: 20-MAY-2014
Sorry for the delay in response. I tried using Version 3 API from Google and when I am trying to get playlists using
var channelsListRequest = youtubeService.Channels.List("snippet,contentDetails");
after setting channelsListRequest.ForUserName, i call var channelsListResponse = await channelsListRequest.ExecuteAsync();
From the response, I would then get the playlist list sent using:
foreach (var channel in channelsListResponse.Items)
{
var uploadsListId = channel.ContentDetails.RelatedPlaylists.Uploads;
var nextPageToken = "";
while (nextPageToken != null)
{
var playlistRequest = youtubeService.Playlists.List("id,snippet,contentDetails,status,player");
playlistRequest.Id = uploadsListId;
playlistRequest.MaxResults = 50;
playlistRequest.PageToken = nextPageToken;
var playlistListResponse = await playlistRequest.ExecuteAsync();
if (playlistListResponse.Items.Count > 0)
MessageBox.Show(playlistListResponse.Items[0].Snippet.Title);
}
The messagebox displays the comment that was added when creating playlist. However, when I view in youtube using a browser, the playlist title is displayed properly.
Please try the following link, and change the play
https://www.googleapis.com/youtube/v3/playlists?part=snippet%2Clocalizations&id=" + playlistId + "&fields=items(localizations%2Csnippet%2Flocalized%2Ftitle)&key=" + KEY;
Implementation and Migration Guide: https://developers.google.com/youtube/v3/guides/implementation
I am new to the YouTube API implementation, so please use the Implementation and Migration Guide above for more information, but from what I have discovered myself using the API Explorer: https://developers.google.com/apis-explorer/#p/youtube/v3/. Is that you need to use youtube.playlists.list(snippet,[id]). Replace [id] with the ID of your playlist.
I am using Google Data API for .Net(version 1.9) in my application.
I have created a Google apps account and i have set the "Users cannot share documents outside this organization" setting under Google Docs.
When i try to share a file outside of the domain(organization) from Google docs web, i get a error saying the file cannot be shared outside of my domain.
But when i try the same thing from the API, it succeeds. I get a 200 success from the API. When i try to access the file from the share link it says 'You need permission to access this resource'. My question is shouldn't the API return with a error? how can i handle this case?
Here is the code that I am using:
DocumentsRequest request = null;
/* request initialization */
string csBatchReqBody = "<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007" xmlns:batch="http://schemas.google.com/gdata/batch"><category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/acl/2007#accessRule"/><entry><id>https://docs.google.com/feeds/default/private/full/document:1DsELtiNwq-ogOrp8cAONdMpGR4gBF79PjijTae-vVNg/acl/user:myusername#mydomain.com</id><batch:operation type="query"/></entry><entry><batch:id>1</batch:id><batch:operation type="insert"/><gAcl:role value="reader"/><gAcl:scope type="user" value="myusername#gmail.com"/></entry>"
string Url = "https://docs.google.com/feeds/default/private/full/document:1DsELtiNwq-ogOrp8cAONdMpGR4gBF79PjijTae-vVNg/acl/batch";
byte[] byteArray = Encoding.ASCII.GetBytes(csBatchReqBody);
MemoryStream inputStream = new MemoryStream(byteArray);
AtomEntry reply = request.Service.Insert(new Uri(Url), inputStream, "application/atom+xml", "");
MemoryStream stream = new MemoryStream();
reply.SaveToXml(stream);
The API actually returns a 400 if you try to share a file outside the domain and the admins have set the "Users cannot share documents outside this organization" flag.
Your code sends a batch request (even if for a single element), you'd have to check the batch response to notice the error.
Instead, use the following code to share a document to a single user, it assumes that entry is the DocumentEntry you want to share:
AclEntry acl = new AclEntry();
acl.Scope = new AclScope("username#gmail.com", "user");
acl.Role = new AclRole("reader");
acl = service.Insert(new Uri(entry.AccessControlList), acl);