Search code examples
microsoft-graph-apionedrive

I am trying to upload an file to a shared folder, the folder is shared by other user , need to add an file using api,


This is the pattern url pattern i tried

POST
https://graph.microsoft.com/v1.0/drives/{shareduserdriveid}/items/{shareduserFolderitemId}, 

{
  "name": "Team Documents",
  "remoteItem": {

      "parentReference": { "driveId": "sharedusersdriveid" }
  }
}

Can someone please provide right url and body pattern for adding or uploading an file to a existing shared folder


Solution

  • You need to POST to the children collection, so a url like the one below should work:

    POST https://graph.microsoft.com/v1.0/drives/{shareduserdriveid}/items/{shareduserFolderitemId}/children

    {
    "name":"test.txt",
    "file": {}
    }