Using MS Graph API to upload large files. Is it possible to send metadata when we create an the upload session?

Pierre-Yves Rosat 1 Reputation point
2021-12-21T10:41:32.133+00:00

During the /createUploadSession request I submit in the payload the following JSON:

{
  "item": {
      "@odata.type": "microsoft.graph.driveItemUploadableProperties",
      "@microsoft.graph.conflictBehavior": "rename",
      "name": "largefile.dat"
    }
}

Server return HTTP error 400.

If I submit only one key-value like this

{
      "item": {
          "name": "largefile.dat"
        }
 }

server return HTTP 200 !

How to add multiple keys in the same payload request?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,785 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,901 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Srinivasa Rao Darna 6,716 Reputation points Microsoft Vendor
    2022-02-14T13:03:33.847+00:00

    Hi @Pierre-Yves Rosat ,

    The documentation is mentioning usage of POST for createUploadSession, when I tested this in Postman even I have same problem 400 Bad request.

    POST /sites/{siteId}/drive/items/{itemId}/createUploadSession  
    

    After testing it multiple times using PUT for createUploadSession is working.

    PUT /sites/{siteId}/drive/items/{itemId}/createUploadSession  
    

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.