Reputation: 41
We are getting lots of file not found errors. When calling the API, we have a slim chance of getting the file. We are having this issue in production and it is affecting clients. This started earlier yesterday. We've been calling this api for months without issue. This is the API we're using.
https://TENANT-my.sharepoint.com/_api/v2.0/drives/DRIVE_ID/items/FILE_ID/content
Using Postman, the response is below. This document is shared properly and has been for months. Nothing changed on our side.
Sorry, something went wrong Sorry, you cannot access this document. Please contact the person who shared it with you. Technical Details
Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: fb6bbf9d-d0d6-2000-cdd6-ef99686d513f
Date and Time: 12/9/2016 9:13:02 AM
Upvotes: 2
Views: 858
Reputation: 41
While this doesn't explain the how or why the API broke, as of this writing, OneDrive has not acknowledged nor fixed the original issue, our solution was to use the value of the @contentDownloadUrl from the meta of the file and make a call to that url without the authorization header.
The docs currently state:
"Pre-authenticated download URLs are only valid for a short period of time (a few minutes) and do not require an Authorization header to download."
This should not say "do not require", but "must not include", as it would be more clear. I have made a pull request to their docs.
Upvotes: 2
Reputation: 11
The issue is with authentication. This code seems to fix it:
var adalAuthProvider = new AdalAuthenticationProvider(
this.AadClientId,
this.AadReturnUrl);
this.oneDriveClient = new OneDriveClient(this.AadTargetUrl + "/_api/v2.0", adalAuthProvider, new HttpProvider(new HttpClientHandler { AllowAutoRedirect = true }, true));
authTask = adalAuthProvider.AuthenticateUserAsync(this.AadTargetUrl);
try
{
await authTask;
}
Upvotes: 0
Reputation: 11
We have the same problem using the C#/.NET SDK with ItemNotFound error and 'Microsoft.Graph.ServiceException'. This started after MS did an update to OneDrive on 12/7. We opened a support ticket with O365/OneDrive team. They said they are not aware of any issues from rollout and said we needed to contact API support. The weird thing is it works sometimes, maybe 2 out of 100 tries. Listing files and uploading still work but downloads fail.
Here's what we have tried so far:
The line of code that fails is:
var stream = await this.oneDriveClient.Drive.Items[item.Id].Content.Request().GetAsync();
Upvotes: 0