/me/drive/sharedWithMe endpoint only returns 1 item in my app but many items in the GraphExplorer

Mikkel Munck Rasmussen 0 Reputation points
2025-11-11T10:34:00.6566667+00:00

When I do a request to this endpoint:https://graph.microsoft.com/v1.0/me/drive/sharedWithMe?$select=name,id,folder,remoteItemIn the graph explorer I get a response with all items shared with me.

However when I do the exact same request in my app, I get a response with only 1 item(that is identical to the first item in the response received in the graph explorer).

These are the scopes I use when setting up the request

    scopes: [
      "Files.Read.All",
      "Files.ReadWrite.All",
      "Sites.Read.All",
      "Sites.ReadWrite.All",
    ], // This is the scope for accessing OneDrive

And in Entra Id these are approved

User's image

This is a strange issue, that started appearing without us changing our app code. Where could this issue lie?

Microsoft 365 and Office | Development | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kha-N 3,835 Reputation points Microsoft External Staff Moderator
    2025-11-11T12:22:33.56+00:00

    Hi @MikkelMunckRasmussen,

    Welcome to Microsoft Q&A, and thank you very much for reaching out to us.

    Please note that as a Microsoft Q&A moderator, I do not have access to your specific configuration, and my testing environment is limited. However, I’ll do my best to assist you as much as possible.

    Based on your description, I tested the same endpoint in Graph Explorer and confirmed that it returns multiple items shared with me in my testing environment. Since your application also returns the same first item, this suggests the issue is unlikely related to permissions.

    To help troubleshoot further, could you share the relevant portion of your application code? This will allow me to check if anything in the implementation might be causing the behavior.

    In the meantime, here are some suggestions you can try to see if it helps mitigate the issue:

    Include external items:

    By default, the endpoint only returns items shared within the same tenant. If most of your shared items come from external organizations, they will be excluded unless you append allowexternal=true.

    You can update your request URL to included it, for example:

    https://graph.microsoft.com/v1.0/me/drive/sharedWithMe?allowexternal=true&$select=name,id,folder,remoteItem
    

    Then test this endpoint in Graph Explorer and your app to see if this the was the cause.

    Handle Pagination:

    The /me/drive/sharedWithMe endpoint doesn’t return everything in one go, it uses paging.

    Each response includes up to about 200 items, and if there are more, you’ll see an @odata.nextLink property with a URL for the next page. You need to keep calling that URL until no @odata.nextLink remains. There’s also a hard cap of roughly 500 items across all pages.

    By default, Graph Explorer automatically follows these links and shows you the full set, but your app might only read the first page. If that first page happens to contain just one item, then it will display that one item.

    To fix this, the app can check for @odata.nextLink and loop until it’s gone. For example:

    let url = 'https://graph.microsoft.com/v1.0/me/drive/sharedWithMe?$select=name,id,folder,remoteItem';
    const items = [];
    
    while (url) {
      const res = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}` } });
      const data = await res.json();
      if (data.value) items.push(...data.value);
      url = data['@odata.nextLink'] || '';
    

    Note that You can use $top to control how many items come back per page (up to 200), but you can’t skip pagination entirely.

    For more information, feel free to check on this Microsoft Article about pagination here.

    Thank you for your time, I am looking forward to your response.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.