1

I am able to use Microsoft API to upload file to folder shared within the same domain. For example, user1@mycompany.com share a directory to user2@mycompany.com, then I am able to write to the shared folder via user2@mycompany.com.

More specifically, I am able to create an upload session using following API:

https://graph.microsoft.com/v1.0/drives/<drive_id>/items/<dir_id>:/<filename>:/createUploadSession

However, the same API would return 404 if the drive_id and dir_id is from user of another domain. For example, another@othercompany.com share folder to user2@mycompany.com, then upload file via user2@mycompany.com.

The error message from API is

{
    "error": {
    "code": "itemNotFound",
    "message": "The resource could not be found.",
    "innerError": {
        "request-id": "526d86bc-c620-4782-a74d-c8cd8284df8b",
        "date": "2018-10-19T20:54:37"
        }
    }
}

Is there any API that would work for OneDrive file upload to shared folder across different domains?

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63
James Tan
  • 15
  • 2
  • Possible duplicate of [Microsoft Graph: Uploading files to shared with me folder on OneDrive?](https://stackoverflow.com/questions/48142134/microsoft-graph-uploading-files-to-shared-with-me-folder-on-onedrive) – Marc LaFleur Oct 22 '18 at 15:40
  • This is different than "shared with me" folder as I am interested in cross domain sharing. It also looks like that cross domain sharing requires no login, anyone who with the link from email received will able to upload via browser. – James Tan Oct 23 '18 at 18:05

1 Answers1

0

at this point you can only access drives from the organization of the authenticated account. If alice@company1.com shares with bob@company2.com and bob@company2.com has a guest account in the company1 organization, then I believe if you log into company1 with the external guest account, then you'll be able to access the shared drive.

Alternatively, if your app is able to authenticate to both accounts, you might be able to take advantage of the fact that upload and download URLs are self-authenticating and do something like this:

  1. using auth token for alice@company1.com, call createUploadSession on the folder.
  2. using auth token for bob@company2.com, download file that is to be shared.
  3. using upload url from #1, upload the file (no other auth token needed here)
daspek
  • 1,414
  • 1
  • 10
  • 10