Hi Roshan Raj A K,
Thanks for reaching out to Microsoft!
The error code 400 typically indicates a bad request. This could be due to an incorrect URL or missing parameters. In your case, it seems like the URL for creating the upload session might be incorrect. The URL should point to the specific item in the drive where you want to upload the file.
I tried from my end and was able to successfully get a success response. I retrieved the itemId
by using the following API:
GET https://graph.microsoft.com/v1.0/sites/{siteId}/drive/root/children
This API lists all items in the root directory, from which you can select the itemId
corresponding to the target folder. Ensure that you replace {siteId} with the actual site ID.
Once you have the correct itemId
, you can use it in the URL for creating the upload session:
POST https://graph.microsoft.com/v1.0/sites/{siteId}/drive/items/{itemId}/createUploadSession
Make sure all required headers and parameters are included in your request.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.