I need to connect to a Sharepoint with API, download list of file from API and then download it.
I've tried to create App in Microsoft Entra and give it all rights with "sites.fullcontrol.all" But it doesn't work.
When I use GetFolderByServerRelativePath()
I get this response :
{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}
I am not sure which endpoint I've to use.
Can someone say me which endpoint use please ?
Initially, I too got same error when I used GetFolderByServerRelativePath() with token generated with MS Graph scope:
Response:
In my case, I registered one Azure AD application and granted API permissions of Application type as below:
Now, I generated access token using client credentials flow via Postman like this:
Response:
You can use this token to call below Graph API query that list files along with download URL:
Response:
Now, click on that download URLs from response where files will be downloaded successfully like this:
Reference: azure - Download File from Secure Sharepoint using Rest API - AudienceUriValidationFailedException - Stack Overflow