none
Onedrive Upload API uploads corrupt file or Image RRS feed

  • Question

  • Hi,

    I am using Onedrive Rest API to Upload a file into my onedrive Account. Below is the mentioned Microsoft documentation link to the Upload file.

    https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online

    Whenever I used the above API the file gets uploaded into my account but the file gets corrupted.

    Below mentioned is my request object.

    {
    method: "PUT",
    url:Ppload Url,
    processData: false,
    headers: {
         "Authorization": <access_token> 
         "Content-Disposition": 'form-data; name="metadata"',
         "Content-Type": "application/json; charset=UTF-8",
         "Content-Transfer-Encoding": "8bit"
        },
    "formData": {
     file: {
           value: fs.createReadStream("Smile.png"),
            options:
              {
                filename: "Smile.png,
                contentType: null
              }
           }
          }
    }



    Can some one Please help me with this.


    Tuesday, November 5, 2019 3:09 PM