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

Sachin Kumar 1 Reputation point
2021-09-14T07:33:49.327+00:00

Hi

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.
10,646 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 37,216 Reputation points
    2021-09-15T09:31:55.887+00:00

    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:

    132168-image.png

    132318-301.png

    ----------

    Update:

    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
    2021-09-16T09:04:04.177+00:00

    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.