How do I resolve 'Invalid request' error on Logic App for http POST action?

Vivek Komarla Bhaskar 756 Reputation points

I have a logic setup with an HTTP POST action to retrieve a token, I have implemented my logic app as follows, but whenever I execute it, I receive the error 'Invalid request'. On Postman, the same works, but not here. How can I fix this?Screenshot 2023-03-06 at 11.40.29 am

Screenshot 2023-03-06 at 11.43.32 am

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,383 questions
0 comments No comments
{count} votes

Accepted answer
  1. Sonny Gillissen 2,381 Reputation points

    Hi @Vivek Komarla Bhaskar

    Thank you for reaching out on Microsoft Q&A!

    An endpoint for token requests usually supports the "application/x-www-form-urlencoded" content type, as is the case in your system as well when referring to the screenshots you shared. In that case the body should not be formed as a JSON, but as a "query string" like below:

    User's image

    You can use my query string below as reference, by changing the values to match yours:


    Please click "Accept answer" if this answer is helpful, and upvote it. Feel free to drop additional comments below :-)

2 additional answers

Sort by: Most helpful
  1. Alistair Ross 7,041 Reputation points Microsoft Employee

    Hello @Vivek Komarla Bhaskar

    I am hoping I can answer this with some trouble shooting steps as you have obscured the URL, therefore I cannot look up what is required (if it is a Microsoft URL for example)

    The issue here most likely won't be with the logic app, but the service you are trying to get the token from.

    • Can you verify the post request works from another service, such as PowerShell or
    • Have you got all the required properties in the body not too many? It does seem strange to be providing a client secret and password in the same request, typically it would be one or the other when requesting a token, from my understanding.
    • Is the headers correct? Are you sure the content type isn't meant to be application/x-www-form-urlencoded ?

    Kind Regards


  2. MayankBargali-MSFT 60,876 Reputation points

    @Vivek Komarla Bhaskar Thanks for reaching out. As you are using Content-Type as application/x-www-form-urlencoded so the body in most case will be below and not as the JSON object. Please validate if this is not the case as you are getting 400 errors that means that the request was not correctly formed.



    In case if the above doesn't help then please share the fiddler/postman request screenshot that you are passing so I can assist you further.

    Please accept as "Yes" if the answer is helpful so that it can help others in the community. If you need any help/clarification/concerns/follow up questions, then please click on "Add Comment" on my answer and provide more details.