Unable to access file shared with me via Graph API

Miles Priestman 1 Reputation point
2021-02-11T00:24:45.643+00:00

A file has been shared with me from another organisation, I can view this via the endpoint /drive/sharedWithMe?allowexternal=true
However, when I try to load the file via /drives/{drive_id}/items/{item_id}/content, I receive the following error:

Error: 404 Client Error: Not Found for url: https://graph.microsoft.com/beta/drives/{drive_id}/items/{item_id}/content | Error Message: Item not found

Is there a workaround for this error?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,421 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Danstan Onyango 3,816 Reputation points Microsoft Employee
    2021-02-15T08:34:01.993+00:00

    You must be trying to access the item from your drive-id. Try using the details in the remoteItem in the sharedWithMe response. The sharedWithMe Docs explains how to use the remote item. You endpoint should be GET /drives/{remoteItem-driveId}/items/{remoteItem-id}/content

    0 comments No comments

  2. Stephan Methner 116 Reputation points
    2021-02-16T13:43:53.7+00:00

    @DanstanOnyango-6080

    Hi Danstan,

    I have a similar problem. I'm calling the sharedWithMe with allowexternal=true and I get a perfect list of items. All with a "remoteItem" (record is at the bottom of my post).

    The GET call works fine for the sending user (in this case "stephan@pipetrend.io"):

    https://graph.microsoft.com/v1.0/drives/b!WWpg2iE5G0eg5c8n4pIe1AH4UNNPmuNHmXLHxQW2L9QS2KywdKQ5RKdYB_W_3fIz/items/01DG3P2BK7YAAQCKHOKZGKDIOYWHPYQKM7

    But when I run this GET as the invited external user (in this case "stephan@airrange.io") I get an "invalidRequest" error.

    I've used both id's... the id from parentReference... and the "driveItemId".

    Can you please help

    Thanks
    Stephan

    ----------

    @odata.type: "#microsoft.graph.driveItem"  
    id: "01DG3P2BK7YAAQCKHOKZGKDIOYWHPYQKM7"  
    lastModifiedDateTime: "2021-01-09T23:50:34Z"  
    name: "Startup Reporting Sharing.xlsx"  
    remoteItem:  
    createdBy: {user: {…}}  
    createdDateTime: "2021-01-09T23:50:34Z"  
    file:  
    mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"  
    __proto__: Object  
    fileSystemInfo: {createdDateTime: "2021-01-09T23:50:34Z", lastModifiedDateTime: "2021-01-09T23:50:34Z"}  
    id: "01DG3P2BK7YAAQCKHOKZGKDIOYWHPYQKM7"  
    lastModifiedBy: {user: {…}}  
    lastModifiedDateTime: "2021-01-09T23:50:34Z"  
    name: "Startup Reporting Sharing.xlsx"  
    parentReference:  
    driveId: "b!WWpg2iE5G0eg5c8n4pIe1AH4UNNPmuNHmXLHxQW2L9QS2KywdKQ5RKdYB_W_3fIz"  
    driveType: "business"  
    id: "01DG3P2BN6Y2GOVW7725BZO354PWSELRRZ"  
    __proto__: Object  
    shared:  
    scope: "users"  
    sharedBy: {user: {…}}  
    sharedDateTime: "2021-01-09T23:55:09Z"  
    __proto__: Object  
    sharepointIds: {listId: "b0acd812-a474-4439-a758-07f5bfddf233", listItemId: "58", listItemUniqueId: "0101c05f-ee28-4c56-a1a1-d8b1df88299f", siteId: "da606a59-3921-471b-a0e5-cf27e2921ed4", siteUrl: "https://netorgft6863818-my.sharepoint.com/personal/stephan_pipetrend_io", …}  
    size: 259528  
    webDavUrl: "https://netorgft6863818-my.sharepoint.com/personal/stephan_pipetrend_io/Documents/Startup%20Reporting%20Sharing.xlsx"  
    webUrl: "https://netorgft6863818-my.sharepoint.com/personal/stephan_pipetrend_io/_layouts/15/Doc.aspx?sourcedoc=%7B0101C05F-EE28-4C56-A1A1-D8B1DF88299F%7D&file=Startup%20Reporting%20Sharing.xlsx&action=default&mobileredirect=true"  
    __proto__: Object  
    size: 259528  
    webUrl: "https://netorgft6863818-my.sharepoint.com/personal/stephan_pipetrend_io/_layouts/15/Doc.aspx?sourcedoc=%7B0101C05F-EE28-4C56-A1A1-D8B1DF88299F%7D&file=Startup%20Reporting%20Sharing.xlsx&action=default&mobileredirect=true"