I am having difficulty forming the url for the call. Examples in tutorial are given in a different way than the url I have.
the url I want to call; https://blahblah.sharepoint.com/teams/projectname/Lists/listname/AllItems.aspx?skipSignal=true
the url structure on the tutorial;
GET /sites/{site-id}/lists/{list-id}?expand=columns,items(expand=fields)
List list = graphClient.sites("{site-id}").lists("{list-id}")
.buildRequest()
.get();
https://learn.microsoft.com/en-us/graph/api/list-get?view=graph-rest-1.0&tabs=java
The first URL (with AllItems.aspx
) is the URL to display the list in your web browser (with the interface, logo, navigation, etc.). To get only data in JSON, you can use Graph API
(but also REST API
). The documentation for Graph API is correct.
So, the URL for Graph API should be:
https://graph.microsoft.com/v1.0/sites/YOUR-SITE-GUID/lists/YOUR-LIST-GUID/items?expand=fields
You can get the GUID of your site with this URL:
https://your-tenant.sharepoint.com/sites/your-site/_api/site/id
For the list GUID, similarly, you get it with this URL:
https://your-tenant.sharepoint.com/sites/your-site/_api/web/lists
It's probably easier to get data with REST API, and not Graph API, with this URL. You can test it directly in your web browser:
https://your-tenant.sharepoint.com/sites/your-site/_api/web/Lists/getByTitle('YOUR-LIST-TITLE')/items