In a list I have some items. I want to call Rest api to list these items.
When I call the api url from the browser, I get the expected result (items are returned).
When I call the api from Insomnia Rest client, I get no result. By no result I mean the result set is returned without error, but empty.
What I've done :
- in AAD portal, I registered a new application, a client ID and an App Secret.
- I autorize (admin consent) :
- Microsoft Graph :
Sites.Read.All
andSites.ReadWrite.All
- SharePoint :
Sites.FullControl.All
,Sites.Manage.All
,Sites.Read.All
andSites.ReadWrite.All
- Microsoft Graph :
- in insomnia, I set up OAuth 2.0 authentication :
- Grant type : Authorization Code
- Authorization Url :
https://login.microsoftonline.com/common/oauth2/authorize?resource=https://mytenant.sharepoint.com
- Access token Url:
https://login.microsoftonline.com/common/oauth2/token
- Client ID:
my generated client ID
- Client secret :
my generated secret
- Redirect URL :
https://login.microsoftonline.com/common/oauth2/nativeclient
- Header : only
Accept
=application/json;odata=verbose
because authentication headers are handled by insomnia.
The url I target is https://mytenant.sharepoint.com/sites/mysitecoll/_api/Web/Lists(guid'b6e9527d-a902-4b15-b77b-d49e701fdd92')/items
.
The result of this call is (status 200 OK
):
{
"d": {
"results": []
}
}
As you can see there's no error, but no data.
What's puzzling me is that calling : https://mytenant.sharepoint.com/sites/mysitecoll/_api/Web/Lists(guid%27b6e9527d-a902-4b15-b77b-d49e701fdd92%27)?%24select=ItemCount
actually returns :
{
"d": {
"__metadata": {
....
},
"ItemCount": 3
}
}
There is data.
What's missing ?
As a side note, using the Graph, everything is ok : https://graph.microsoft.com/v1.0/sites/mytenant.sharepoint.com,b969074a-6a95-4235-a520-17893eca8fbe,4d32dad1-6bcc-4b57-becc-7e476c851046/lists/b6e9527d-a902-4b15-b77b-d49e701fdd92/items returns expected data