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

Community site session details

Session Id :
Power Automate - Using Connectors
Answered

401 unauthorized when sending Post HTTP request

(0) ShareShare
ReportReport
Posted on by 11

Hi all,

 

I'm working on a flow that will trigger a post request toward a custom Business central OData API.

I'm having issue configuring the Oauth in power automate, i tried with two different methods but all I get is a 401 unauthorized ("The credentials provided are incorrect") error.

This first method I tried was by using a Send http request block with OAuth Active Directory authentification :

VMotin_0-1693559620120.png

 

The second method i tried was by retrieving the token myself with a post method toward my /token url and then using this token in an Authorization header 

VMotin_1-1693559705683.png

The post method to obtain the token works fine but i get the same error when posting :

<error xmlns="http://docs.oasis-open.org/odata/ns/metadata"><code>Unauthorized</code><message>The credentials provided are incorrect</message></error>

 

The request works fine in postman with an oauth 2.0 authentification method.

 

Any idea of what could be the issue ? 

 

Thanks

 

I have the same question (0)
  • Michael E. Gernaey Profile Picture
    52,857 Super User 2025 Season 2 on at
    Re: 401 unauthorized when sending Post HTTP request

    Hello,

     

    Can you do a little test. Can you create a flow that takes in an Access Token and then calls the Business Central endpoint?

     

    Make that, then use Postman to create the bearer token and then paste it in and see if it works. If so, then it means the token being created is not being formatted properly OR, that bearer token is valid BUT it doesn't have the correct permissions associated to it.

     

    I see that you are getting a 401 unauthorized, which is different than a 400 bad token, so i wonder if the issue is simply who the flow is running as so when the token gets created its just not valid for that call.

     

    Does the flow run as you (since post man does)? If not, can you make it do that, do the test with the postman token, then do the test as normal and see what works and doesn't and come back.


    Cheers
    If you like my answer, please Mark it as Resolved
    and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | Ex-Microsoft

    Site: https://gernaeysoftware.com

    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Verified answer
    VMotin Profile Picture
    11 on at
    Re: 401 unauthorized when sending Post HTTP request

    Hi @FLMike , thanks for your answer,

     

    I was able to solve my issue, 

    I didn't register my API in Business central in the Application Azure AD which is why it was unauthorized.

    VMotin_0-1694425654127.png

     

    After I did that, I just needed to add the proper authorizations to my user and it was good to go !

  • Michael E. Gernaey Profile Picture
    52,857 Super User 2025 Season 2 on at
    Re: 401 unauthorized when sending Post HTTP request

    Ah so in fact it was the user that the app was running as (in your case its an onbehalf situation with the app being promoted to do the work, once you added it).

     

    Glad you got it working. Pretty much any time you get that error, as mentioned, it means the user submitting the request doesn't have privileges. Then its just a matter of if its an on behalf of flow or a as user flow.
    Cheers
    If you like my answer, please Mark it as Resolved, and give it a thumbs up, so it can help others
    Thank You
    Michael Gernaey MCT | MCSE | Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

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

Coming soon: forum hierarchy changes

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
Tomac Profile Picture

Tomac 544 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 482 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 287

Last 30 days Overall leaderboard

Featured topics