Microsoft Graph API Java SDK: Get a site with its

2019-09-21 06:23发布

问题:

I am using the Microsoft Java SDK for Graph API.

I want to access a site via its server relative path like

GET https://graph.microsoft.com/v1.0/sites/company.sharepoint.com:/sites/mysite:/

I can only find in the SDK something for find by ID apposed to relative path? I dont have the ID

The URL of my site is like this https://mycompanydomain.sharepoint.com/sites/my_site_name

回答1:

The trick is to get the root of the relative path and then navigate from it using the path you have. So something like:

sites.byId("company.sharepoint.com").getByPath("/sites/mysite").buildRequest().get();

This should result in a request to Graph that looks like the one you specified.



回答2:

The solution was actually to do sites.byId("company.sharepoint.com:/sites/mysite:").buildRequest().get();