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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,715 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,686 questions
0 comments No comments
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,696 Reputation points Microsoft Vendor
    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