Reputation: 181
I created an Azure AD application that has full access (R&W) to the OneDrive API using application permissions. (my application is a daemon app.) These permissions are granted & approved.
HTTP GET https://{MyTenant}.sharepoint.com/_api/v2.0/drives//root://Document.docx
Returns 200 and content contains JSON information about the file
GET 2016-12-24T14:15:31.458 Requested uri:
https://{MyTenant}.sharepoint.com/_api/v2.0/drives//root://Document.docx:/content
2016-12-24T14:15:31.888 StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { X-SharePointHealthScore: 0 SPRequestGuid: c935c49d-a0fa-3000-a357-32b18090ecd4 request-id: c935c49d-a0fa-3000-a357-32b18090ecd4 Strict-Transport-Security: max-age=31536000 X-FRAME-OPTIONS: SAMEORIGIN SPRequestDuration: 140 SPIisLatency: 1 MicrosoftSharePointTeamServices: 16.0.0.6008 X-Content-Type-Options: nosniff X-MS-InvokeApp: 1; RequireReadOnly Cache-Control: private Date: Sat, 24 Dec 2016 14:15:31 GMT 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" Server: Microsoft-IIS/8.5 WWW-Authenticate: NTLM X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Content-Length: 16 Content-Type: text/plain; charset=utf-8 } 2016-12-24T14:15:31.888 401 UNAUTHORIZED
I added the Authorization header correctly. I created an Upload Function that sends the file to the same Document library and that works also correctly, same with the Delete functionality.
What is the reason of this 401, only when requesting the /content of the file? How could I troubleshoot this?
I loaded the JWT token into jwt.io : It has the following Roles : "roles": [ "TermStore.ReadWrite.All", "Sites.Manage.All", "TermStore.Read.All", "Sites.Read.All", "Sites.ReadWrite.All", "Sites.FullControl.All" ]
What is going on here? The requested URI is : https://<myTenantName>.sharepoint.com/_api/v2.0/drives/<myDriveName>/root:/faas.pptx:/content
When using both types of GET request GET /drive/items/{item-id}/content GET /drive/root:/{path and filename}:/content -> return 401 Unauthorized
Best regards,
Jens
Upvotes: 1
Views: 415
Reputation: 4192
This is unfortunately a long running issue with OneDrive for Business and "app-only" scenarios. You can keep track of the issue over at https://github.com/OneDrive/onedrive-api-docs/issues/280.
Upvotes: 1