How to find site id for Onedrive account for graph API

Hardik Shah 61 Reputation points
2022-11-08T12:29:30.46+00:00

I want to create shared link for my file in Onedrive using API, I am trying to follow https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createlink?view=odsp-graph-online , here I want to use

POST /sites/{siteId}/drive/items/{itemId}/createLink API

I found that by using Microsoft Graph API, we can achieve this, I found https://devblogs.microsoft.com/microsoft365dev/controlling-app-access-on-specific-sharepoint-site-collections/ article as well which describes minimal permissions for my account. Due to this need, I want to use above API.

for my Onedrive account, how do I find siteId associated to my Onedrive account ?

Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-11-08T13:39:32+00:00

    Hi anonymous user-4624,

    You can use GET /me/drive/SharePointIds to get associated sharepointids that returns siteId.

    258302-image.png

    Use the siteId to get sitecollection associated with your OneDrive.

    258220-image.png

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.