5
votes

Working with the Microsoft graph api and especially the sharepoint beta api and i am constantly running into issues. I know its beta, but still;)

SO the issue is When i tried to access the sharepoint list using Graph API in graph explorer URL is: GET https://graph.microsoft.com/beta/sites/{site-id}/lists/{list-id}

So SiteID i am passing my site tenant GUID and List ID as Sharepoint List GUID and i am facing the error continously in Response

{ "error": { "code": "invalidRequest", "message": "Provided id is not suitable for the current host", "innerError": { "request-id": "61efc5b1-88f8-442c-a41d-7213b587318e", "date": "2017-05-10T07:38:04" } } }

IF any one also has faced this issue please let me know the solution you have resolved

3

3 Answers

12
votes

The format of the ID's for sites have changed as part of a set of updates to the API this week. The new format is documented here, but it includes the SharePoint hostname, SPSite.ID, and SPWeb.ID as a triplet:

https://graph.microsoft.com/beta/sites/contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8

If you add the hostname into your IDs, your calls should start working again. You can discover the hostname by making a request to:

https://graph.microsoft.com/beta/sites/root/siteCollection/hostname

You can also search for sites now using the following search syntax:

https://graph.microsoft.com/beta/sites?search={keyword}
0
votes

Try https://graph.microsoft.com/beta/sites/{siteCollectionId},{siteId}/lists

You can find these ids from https://graph.microsoft.com/beta/site/sites

0
votes

@Ryan Gregg has the correct answer

The SiteId is not just one GUID but a combination of <HostName,SPSite.ID,SPWeb.ID>.

Example: <contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8>

The whole string in the above example is what you should pass for {SiteId} in your request

If you dont have the SPSite.ID but have the URL for the site, you can make a GRAPH API call with relative path to the site

https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Documetation

This call will return all the properties for the site and you can grab the full SiteId from here:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
    "createdDateTime": "2020-04-23T12:18:48.653Z",
    "description": "Documentation",
    "id": "contoso.sharepoint.com,fc016e3c-d8ae-4ee0-a10c-de6d26788b6a,9a4ea7a5-c3c4-44ae-9f80-273bd67431b8",
    "lastModifiedDateTime": "2020-12-09T19:17:21Z",
    "name": "Documentation",
    "webUrl": "https://contoso.sharepoint.com/sites/Documentation",
    "displayName": "Documentation",
    "root": {},
    "siteCollection": {
        "hostname": "contoso.sharepoint.com"
    }
}