How to fix the 401 error when trying to get dataverse data in SPFx webpart ?

Dattatraya Kamthe, Anita 60 Reputation points
2023-10-27T13:26:58.0533333+00:00

I’m trying to connect to dataverse via an app registration in Azure AD but I’m always receiving HTTP 401 responses when I try to get data via the AadHttpClient object (referencing the custom app client id). I’ve enabled the ‘oauth2AllowImplicitFlow’ option in the app registration manifest and granted user_impersontate permission on Dynamics CRM. Also the webApiPermissionRequests were added to the package-solution.json file in the spfx project.

Has something been changed on how to connect to dataverse?

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-10-30T03:05:08.3766667+00:00

    Hi @Dattatraya Kamthe, Anita

    After app registerion, you will need to consume enterprise APIs secured with Azure AD in SharePoint Framework. If you are using enterprise API, you could follow the steps to connect with spfx

    https://learn.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient-enterpriseapi


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.