itemNotFound for file that does exist

Michael Millar 1 Reputation point

I am setting user permissions (read or write) to files stored in OneDrive using the Graph API. The owner of the file is making the call to the API and the BaseURL for the request is in the form:  

This works most of the time, but every now and then, the resource "isn't found" and I get a response like this:

        "error": {
          "code": "itemNotFound",
          "message": "The resource could not be found.",
          "innerError": {
            "date": "2021-02-01T12:19:21",
            "request-id": "ef47abe9-4576-4e14-930e-32638445c87c",
            "client-request-id": "ef47abe9-4576-4e14-930e-32638445c87c"

The resource does exist. Sometimes a retry after a few seconds is successful, sometimes it doesn't seem to be successful for several minutes. This isn't good for users and any help resolving the issue / improving reliability would be gratefully received.


Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,907 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Diya Ahuja 5 Reputation points

    The issue you are experiencing is likely due to the fact that the resource is not always immediately available when the API call is made. This is because the resource may be in the process of being created or updated, and the API call is being made before the resource is ready.

    To improve reliability, you can try adding a delay before making the API call, or you can use the if-none-match request header to check if the resource has been updated since the last time the API call was made. If the resource has not been updated, the API will return a 304 Not Modified response, which can be used to avoid making unnecessary API calls.

    0 comments No comments