How to get siteid , drive id and list items with permissions

Balaji Mogadali 45 Reputation points
2025-01-13T17:09:42.03+00:00

Hi team,

Can you please provide code snippets to get Site Id, Drive ID , Items with permissions.

I'm able to generate GraphServiceClient but while callig DriveID
var drives = await graphClient.Sites[siteId].Drives.; //Here after dot(.) i expect Request but it is not coming.

I installated two packages i.e Azure.Identity and Microsoft.Graph , along with Sites.Read.All / Sites.Manage.All

Please provide working code snippets

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

1 answer

Sort by: Most helpful
  1. Yakun Huang-MSFT 9,855 Reputation points Microsoft Vendor
    2025-01-14T02:07:08.0466667+00:00

    Hello Balaji Mogadali,

    Thank you for reaching out to Microsoft Support!

    Please try the following code snippet:

    var drives = await graphClient.Sites["{site-id}"].Drives.GetAsync();
    

    When you send a request, don't forget to call the GetAsync() method at the end to send the request.

    Reference document:

    https://learn.microsoft.com/en-us/graph/api/drive-list?view=graph-rest-1.0&tabs=csharp

    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.


Your answer

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