Hi @GSH-1402,
Thanks for reaching out to us. We are very pleased to support you.
According to the information you provided and the research I have done, I may understand that you need to use MS Graph to get the site id and document id. If there is anything wrong, please correct me.
If there is not anything wrong, it is suggested that you please try the following solution:
- Get site id Intercept your domain name and site name from your document url and use the following request:
The id property is the site id:GET https://graph.microsoft.com/v1.0/sites/{Your Tenant Name}.sharepoint.com:/sites/{Your Site Name}?$select=ID
- Get document id
- Before getting the document id we need to get the drive id of the document library, please use the following request to get the name and drive id of all the document libraries in the site and then filter by repository name in your application. (Because the request does not support filter, so we can only query the drive id of all the document libraries)
This is the returned response, the id property is the drive id:GET https://graph.microsoft.com/v1.0/sites/{your site id}/drives?$select=id,name
- Use the following request to get information about the file. Note that the relative file path here starts with the folder containing the file and ends with the file name, or directly with the file name if there is no folder.
The etag property in the returned response contains the document id:GET https://graph.microsoft.com/v1.0/sites/{site id}/drives/{drive id}/root:/{relative file path} Example: https://graph.microsoft.com/v1.0/sites/{site id}/drives/{drive id}/root:/TestFolder/test_file.txt
- Before getting the document id we need to get the drive id of the document library, please use the following request to get the name and drive id of all the document libraries in the site and then filter by repository name in your application. (Because the request does not support filter, so we can only query the drive id of all the document libraries)
If you have any questions, please do not hesitate to contact me.
Moreover, if the issue can be fixed successfully, please click "Accept Answer" so that we can better archive the case and the other community members who are suffering the same issue can benefit from it.
Your kind contribution is much appreciated.