sanfalero
sanfalero

Reputation: 382

Invalid Request trying to get Sharepoint Site resource by Path in Graph API

I'm trying to get a Site resource by path using the Rest Graph API as explained in the docs and I'm getting an error message indicating:

Provided identifier is malformed - site collection id is not valid

I'm able to access the SharePoint site through the browser accessing to this URL:

https://<tenant>.sharepoint.com/sites/<site name>

The endpoint I'm forming has the following shape:

https://graph.microsoft.com/v1.0/sites/<tenant>.sharepoint.com:/<site name>

I am able to successfully retrieve Site information by id but not by path. Here is a screenshot of how the request I'm trying to make looks like in Postman.

Postman GraphApi request

This is the response when getting site information by id:

enter image description here

Is the endpoint URL correctly formed for retrieving the site resource information?

Upvotes: 0

Views: 2565

Answers (2)

Baker_Kong
Baker_Kong

Reputation: 1889

Here i tested this endpoint and am able to get site resource.

Site URL:

https://{tenant}.sharepoint.com/sites/{sitename}

Get a site resource by path:

https://graph.microsoft.com/v1.0/sites/{tenant}.sharepoint.com:/sites/{sitename}

result: call endpoint through MS graph explorer

thanks

Upvotes: 0

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59338

When addressing sites by path, the format as follows:

SharePoint hostname, followed by a colon and the relative path to the site

It appears in your example site name specified instead of relative site path:

https://graph.microsoft.com/v1.0/sites/<tenant>.sharepoint.com:/<site name>
                                                                ^^^^^^^^^^ 
                                                      should refer to relative path to the site

instead it should be like this:

https://graph.microsoft.com/v1.0/sites/<tenant>.sharepoint.com:/sites/<site name>

Upvotes: 1

Related Questions