Microsoft Graph API Downloading File Contents Unauthorized 401

I am trying to download a file from SharePoint Online using the app-only token. I can get file information using this URL

https://graph.microsoft.com:443/v1.0/sites/{siteId}/drives/{driveId}/list/items/{itemId}/driveItem

But when I try to upload a file with this URL

https://graph.microsoft.com:443/v1.0/sites/{siteId}/drives/{driveId}/list/items/{itemId}/driveItem/content

I get the following error

403 FORBIDDEN

Content-Length →13
Content-Type →text/plain; charset=utf-8
Date →Fri, 13 Apr 2018 08:47:12 GMT
MicrosoftSharePointTeamServices →16.0.0.7604
P3P →CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
SPIisLatency →2
SPRequestDuration →53
X-Content-Type-Options →nosniff
X-MS-InvokeApp →1; RequireReadOnly
X-MSDAVEXT_Error →917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically.
X-MSEdge-RefRef A: B9E0C567B0CC4E60AEE93EEB8DC06AF1 Ref B: VIEEDGE0813 Ref C: 2018-04-13T08:47:12Z
X-Powered-By →ASP.NET
X-SharePointHealthScore →0

what's wrong?

it seems that inside it generates a download link (... / _ layouts / 15 / download.aspx? UniqueId = ...), which works with the username / pwd token, but does not work with the "application only" token

I have another Office 365 subscription that works with the app-only token. The other subscription has its own domain, but I do not see other differences in the configuration (both have the LegacyAuthProtocolsEnabled property set to true, the same sharing options ...)

EDIT: , , , !

+4
3

. , , API- Graph API/Sharepoint, . :

  • , URL-
  • @microsoft.graph.downloadUrl,
  • , URL-, @microsoft.graph.downloadUrl

, , ,

, : , api,

: fileSystemInfo.lastModifiedDateTime Sharepoint Online

- Mark LeFleur?

+1

@microsoft.graph.downloadUrl, /v1.0/me/drive/list/items/x/driveItem, URL- . GET .

. https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/driveitem#instance-attributes

0

I followed the same example, which was initially unsuccessful and now works for at least two tenants that I have.

I did not change the configuration or the source code, so it seems that this was a temporary problem that was fixed.

0
source

Source: https://habr.com/ru/post/1696146/


All Articles