Search code examples
c#azureazure-logic-apps

Trying to call logic app URL result in authorization scheme or internal token scheme. Only one scheme should be used error


I have an application that is going through the results of a logic app step and needs to get to the URLs

To do this I use a httpClient and use the authorization token provided on the API page here

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "My Bearer token");

I get the error

The request has SAS authentication scheme, 'My Bearer token' authorization scheme or internal token scheme. Only one scheme should be used."

This also happens in Postman as shown below

enter image description here

How do I do this? This happens in code and in Postman


Solution

  • In order to fetch the data of a particular logic app workflow run, you can use the below URL.

    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/workflows/{workflowName}/runs/{runName}?api-version=2016-06-01
    

    Initially you need a token to invoke it. To generate the token, register an application in Microsoft Entra ID as per this MS Docs. Once registration is completed, you will get the Client Id and Tenant Id from the Overview blade as shown below.

    enter image description here

    You need to create a secret in Certificates and Secrets blade. Once you have Tenant Id, Client Id and Client Secret then you can generate the token as shown below.

    URL-

    POST https://login.microsoftonline.com/{Tenant_ID}/oauth2/token
    

    enter image description here

    I have used the above bearer token to fetch the output of a particular workflow run like below-

    enter image description here

    In this way, you use the REST API to get the run of a logic app workflow.