Reputation: 71
I am getting the below error when creating upload session (Microsoft Graph Api).
{ "error": { "code": "invalidRequest", "message": "Invalid request", "innerError": { "request-id": "6e9cc58e-d3b9-456e-a794-90486969296e", "date": "2020-04-06T20:53:18" } } }
Post request https://graph.microsoft.com/v1.0/me/drive/root:/testapi:/createUploadSession
Request body :
Upvotes: 3
Views: 4965
Reputation: 1478
Microsoft Graph API is a PITA. That said, this worked for me:
/drives/${driveId}/${childId}:/${filename}:/createUploadSession
If you are uploading to Sharepoint (instead of OneDrive), be sure to include only valid properties in the body payload (more here). This worked for me:
{
"item": {
"name": "filename.txt"
}
}
Upvotes: 0
Reputation: 1072
I was implementing C# from here where the code was
var uploadSession = await graphClient.Me.Drive.Root
.ItemWithPath(itemPath)
.CreateUploadSession(uploadProps)
.Request()
.PostAsync();
In my case, I was able to fix it by updating itemPath
by adding the full path to the file. For instance, if the path is
/RootFolder/Folder1
just update with file name like this
/RootFolder/Folder1/MyFile.pdf
Upvotes: 0