I want to call Dynamics CRM API from SPFx. What I’ve tried so far.
Code:
this.context.aadHttpClientFactory
.getClient('{ApplicationId}')
.then((client: AadHttpClient): void => {
client
.get('<Organization URL>/api/data/v9.0/accounts?$select=name,address1_city&$top=10', AadHttpClient.configurations.v1)
.then((response: HttpClientResponse): any => {
console.log(response);
return response.json();
});
});
After that, an alert appears which shows the message:
Additional credentials are required to show this page correctly.
If I click Ok
then it will redirect to SharePoint home page. Else if I click Cancel
then it will show me the error:
Error: AADSTS65001: The user or administrator has not consented to use the application with ID ” named ‘SharePoint Online Client Extensibility Web Application Principal’. Send an interactive authorization request for this user and resource.
Tried Solution:
Already Grant Permission in Azure AD app. Permission is set for Dynamics CRM online.
Image Description:
EDIT
Sometimes it shows the error mentioned in the image.
Image Description: