Tim
Tim

Reputation: 13

OneDrive for business API : Can not share file

I have used OneDrive API to upload and get shared (embed) link:

POST /drive/items/{item-id}/action.createLink
Content-Type: application/json
Authorization: Bearer {access token}
{
  "type": "view"
}

And received file with link that could be visible for everyone like "https://onedrive.live.com/redir?resid=5D33DD65C6932946!70859&authkey=!AL7N1QAfSWcjNU8&ithint=folder%2cgif"

But now i am trying to use OneDrive for business API:

POST https://{tenant}-my.sharepoint.com/_api/v2.0/drive/items/{file-id}/action.createLink
Content-Type: application/json
Authorization: Bearer {access token}
{
  "type": "view"
}

And it returns

   401 Unauthorized

   error: {
            code: "unauthenticated"
            message: "The caller is not authenticated."
          }

Also i have searched for this functionality on https://msdn.microsoft.com/en-us/office/office365/api/files-rest-operations#Fileoperations for v1.0 business API, but there is nothing about sharing files at all.

P.S: All operations related to getting metadata, uploading file, removing file is working on both API versions for "OneDrive for business".

I am wondering if using of OneDrive will even help me to store some file and getting public embed link for it...

P.P.S: i am using HttpClient object to work with native REST API, but i don`t think that problem is on my side...

Upvotes: 0

Views: 405

Answers (1)

Tim
Tim

Reputation: 13

Its working now, seems like there was some problems on API side

Upvotes: 0

Related Questions