Microsoft Graph api for onedrive upload file uploads file metadata by default

Sachin Kumar 1 Reputation point


I need to upload only contents of the file without metadata. Tried different ways of calling the api it always puts the metadata ( headers - Content-Type: application/json Content-Disposition and file name ) are getting added as part of the file.

api is - /me/drive/root:/FolderA/FileB.txt:/content

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,139 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 39,101 Reputation points

    I tried to call the api to upload the text, but it did not upload the metadata to the file content. I tested it locally and there should be no problem. Can you tell me your operation process? This is my test result:





    It has been confirmed that this is by design. When you upload a file in onedrive/sharepoint it adds the metadata - by default.

    0 comments No comments

  2. Sachin Kumar 1 Reputation point

    This UI works fine as we put the contents of the file in the request body. In our case we are trying to upload a file from postman and we provide Multipart/forma-data as content-type and upload the file directly then it adds the metadata along with content to the uploaded file.