Microsoft Graph API OneDrive Sync Status for files?

Ward Horsfall 101 Reputation points
2022-01-27T12:12:48.263+00:00

Hi,

How can I in C# use the Microsoft Graph API to check my OneDrive for business files have been synced?

I would like to be able to enumerate through all the object and check if they have been synced or are in the process of syncing and the other states.

Thanks,

Ward

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

Accepted answer
  1. ShivaniRai-MSFT 2,726 Reputation points
    2022-02-25T14:34:03.527+00:00

    Hi @Ward Horsfall ,

    As per this Documentation which you already mentioned, you can use these Graph API Endpoints:

    GET /drives/{drive-id}/items/{item-id}/children  
    GET /groups/{group-id}/drive/items/{item-id}/children  
    GET /me/drive/items/{item-id}/children  
    GET /sites/{site-id}/drive/items/{item-id}/children  
    GET /users/{user-id}/drive/items/{item-id}/children  
    

    to enumerate all the items in your drive. In the documentation you can find equivalent c# code. For example c# code for this Endpoint GET /me/drive/root/children is like below:

    GraphServiceClient graphClient = new GraphServiceClient( authProvider );  
      
    var children = await graphClient.Me.Drive.Root.Children  
    	.Request()  
    	.GetAsync();  
    

    Example Reference: You can refer below example to see response of this API https://graph.microsoft.com/v1.0/me/drive/root/children in Graph Explorer:
    177932-image.png

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rakesh Bhavsar 21 Reputation points
    2022-12-29T14:39:00.903+00:00

    Hello,

    Issue: I am successfully able to upload file (few MB size) into OneDrive programatically using graph api using functional/generic account, however newly uploaded file is not showing to user with whom respective OneDrive folder is already shared befor upload.

    Steps:

    1. There is a OneDrive folder shared by a generic/functional/service account with some human user account. Both are haveing Business account type only.
    2. Upload file into already shared OneDrive folder using some generic functional/service Account programatically using graph API (site.selected api application permission is given into Azure app). File is successfully uploaded as same file can be downloaded successfully using programatically calling graph api.
    3. Issue is that human user unable to see newly uploaded file into given OneDrive shared path. Same user can able to see already existing files.

    Any solution how to handle this issue?

    Would appreciate your response.

    Thank you

    0 comments No comments