title: SharePoint Online: Issues when try to connect to .Net Core API secured with Azure AD using AadHttpClient from SharePoint app
body: <p>SPFx |
  SharePoint Online</p>
  
  <hr>
  
  <p>Hello,
  I have a custom .Net core API uploaded to Azure. I need to connect the secure Azure AD API with the SharePoint client-side web parts (using SharePoint framework v 1.7). To connect to Azure AD I use AadHttpClient.</p>
  
  <p>I receive the following error when opening API management page:
  <strong>[HTTP]:500 - [CorrelationId] {} [Version]:16.0.0.8713 - Unknown Error</strong>
  I see in the development tool that the error comes from: 
  Request URL: /_api/SPOInternalUseOnly.SPOWebAppServicePrincipal/PermissionGrants</p>
  
  <p>I'm a global administrator.</p>
  
  <p>When I try to approve the permission request it shows an error:
  <strong>[HTTP]:400 - [CorrelationId] {}: [Version]:16.0.0.8713 - The service principal for permssion request {projectName}-client-side-solution could not be found.</strong></p>
  
  <p>I try to approve it via Azure powershell <strong>Approve-SPOTenantServicePrincipalPermissionRequest</strong> but I receive the exactly the same error.</p>
  
  <p>package-solution.json contains:</p>
  
  <pre><code>"webApiPermissionRequests": [
    {
      "resource": "{displayName of the registered app}",
      "scope": "user_impersonation"
    } 
  ]
  </code></pre>
  
  <p>In Azure app service settings -> Authentication/Authorization -> Active Directory Authentication --> App Service Authentication is On -> Express -> Use Existing App.</p>
  
  <p>When I execute this I see my service registered there:
  az ad sp list --query "sort_by([*].{displayName: displayName, objectId: objectId}, &amp;displayName)" -o table</p>
  
  <p>I also try to execute Enable-SPOTenantServicePrincipal but receive an error again : Unknown Error</p>
  
  <p>Do you have any ideas?</p>