web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Calling the Power Auto...
Power Automate
Unanswered

Calling the Power Automate REST API manually

(0) ShareShare
ReportReport
Posted on by 281
Trying to call the Power Automate API manually without success. Has anyone been able to do it?
Generating Token works in general, but the resulting token doesn't work to authenticate the call to the actual endpoint:
{
 "error": {
 "code": "InvalidAuthenticationTokenAudience",
 "message": "The access token has been obtained from wrong audience or resource '00000002-0000-0000-c000-000000000000'. It should exactly match (including forward slash) with one of the allowed audiences 'https://service.flow.microsoft.com/','https://management.core.windows.net/','https://management.azure.com/','https://service.powerapps.com/','https://service.kratosapps.com/','637fcc9f-4a9b-4aaa-8713-a2a3cfda1505'."
 }
}
What I have tried is this POST request:
{
 "inputs": {
 "method": "POST",
 "uri": "https://login.microsoftonline.com/<myTenantID>/oauth2/v2.0/token",
 "headers": {
 "content-type": "application/x-www-form-urlencoded"
 },
 "body": "Client_Id=xxx&Client_Secret=xxxx&grant_type=client_credentials&scope=https://service.flow.microsoft.com/.default"
 }
}
also without .default and https://management.azure.com/ instead
and also without v2.0
This is all returning tokens.

Then the actual endpoint:
{
 "inputs": {
 "method": "GET",
 "uri": "https://emea.api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/<myEnvironment>/flows/<myFlowID>/runs?api-version=2016-11-01",
 "headers": {
 "Authorization": "Bearer @{body('Parse_JSON')?['access_token']}"
 }
 }
}
The app/service principal has "Flows.Manage.All"-permissions.
The custom connector runs without any issues with these credentials - just that it cannot handle pagination, so I have to do it manually instead... 
Also, the working custom connector is using "https://service.flow.microsoft.com/" as Resource URL.

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    on at

    Hi @Imke ,

     

    Unfortunately, the power automate api provides delegated permissions instead of application permissions.

    vxiaochenmsft_0-1700461075262.png

    So we cannot use grant type of 'client_credential' here.

    Besides, the scope should be https://service.flow.microsoft.com//.default rather than https://service.flow.microsoft.com/.default

     

    Please try to use other grant type.

    vxiaochenmsft_1-1700461404332.png

     

    Blog reference-

    https://ashiqf.com/2021/05/09/everything-to-know-about-power-automate-rest-api-to-manage-and-administer-your-flows/

     

    Best Regards,

    Wearsky

  • Imke Profile Picture
    281 on at

    Hi @v-xiaochen-msft ,
    thanks, but I don't understand how to apply this to my case here:
    If I am using grant type "Authorization Code" instead, I am asked to provide the code into the request body.
    But according to the blogpost you've mentioned, this code can only be generated by a direct call in the browser. It is supposed to open the auth-window then.
    When I use it in a HTTP-action, I am just getting some HTML back.

     

    Could you please provide me with the exact steps on how to generate a token that would work for the calls to the Power Automate endpoints please?

    Thanks heaps!

     

    Some further background here: The custom connector mentioned in the blog works well, but not for pagination.
    And although I have managed to finally integrate the pagination mechanism in the custom connector, it will give an auth error when calling the nextLink. So my only way to make pagination work for this API seems to be the manual call.
    Otherwise: If you can tell me how to overcome the error in the custom connector call, I would be equally happy with that.

  • Verified answer
    Imke Profile Picture
    281 on at

    Hi @v-xiaochen-msft ,
    we can close this.
    I am using the "HTTP with Azure AD"-action, which handles the auth gracefully.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard