Reputation: 81
Can somebody explain to me how to create Items in Sharepoint
with Microsoft Graph
?
I used this repro IgniteBrk3114
And get Infos
with
var response = await client.GetStringAsync("https://graph.microsoft.com/beta/sharepoint/site/drive/items/root/children?$select=name");
Can I push with PostAsync
now at the same way?
var postResult = await client.PostAsync("https://graph.microsoft.com/beta/sharepoint/site/drive/items/root/children", contents);
Or is it the wrong way? Do I need SharePointClient()
to change?
I also saw this Add Collaboration To Your Mobile Apps with SharePoint, but it dont work right now.
Upvotes: 0
Views: 158
Reputation: 2035
It looks like you are trying to create a file in a Document Library in the SharePoint root site. If that's what you're trying to do, you the syntax is a little different:
var requestUrl = "https://graph.microsoft.com/beta/sharePoint/site/drive/root/children/filename.txt/content";
var requestData = new StreamContent(fileStream) // HttpContent with file contents
var response = await client.PutAsyc(requestUrl, requestData);
POSTing to the children collection is not supported on SharePoint / OneDrive for Business.
Upvotes: 1