'Getting error "invalidRequest" when creating upload session (Microsoft Graph Api)
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 :
Solution 1:[1]
I have modified the request as below to make it work. See below :
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cameojbs |
Solution 2 | pradeepradyumna |