I am trying to create an upload session (ref. https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online) in order to upload a "large" document (any doc that exceeds 4MB). I am leveraging the Graph Explorer, but Graph Explorer does not provide an exact example/code snippet to do this.
I am able to use the following configuration to create my request and retrieve a successful uploadUrl in Graph Explorer
POST v1.0 https://graph.microsoft.com/v1.0/me/drives/{myDriveId}/items/{myItemId}:/test.pdf:/createUploadSession
In my application I am able to call CreateUploadSession successfully, but the uploadUrl return is null.
var graphClient = new GraphServiceClient(authenticationProvider);
var requestBody = new Microsoft.Graph.Drives.Item.Items.Item.CreateUploadSession.CreateUploadSessionPostRequestBody
{
};
var res = await graphClient.Drives["{myDriveId}"].Items["{myItemId}/:/testFile.pdf"].CreateUploadSession.PostAsync(requestBody);
var uploadUrl = res.UploadUrl;
My application is using Microsoft.Graph 5.11
Would this be the correct method when creating my upload session?
Thanks
Dug further into the Items object, I found Items[].ItemsWithPath()
after changing my statement to
var res = await graphClient.Drives["{myDriveId}"].Items["{myItemId}"].ItemWithPath("testFile.pdf").CreateUploadSession.PostAsync(requestBody);
my request is returning a new UploadUrl