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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Invoke Web Service POS...
Power Automate
Answered

Invoke Web Service POST received bad request but works in postman and javascript

(0) ShareShare
ReportReport
Posted on by 169

I run a process where I:

  1. POST to an identity server & retrieve my access token
  2. GET orders from the site's API (using token)
  3. Iterate through the orders to create a "Dispatch" object that is needed to process (release) the orders
  4. POST the "Dispatch" to the site's API to process the order (using token)

Step #4 above fails with a 400, Bad Request.

 

I write the "Dispatch" object to a file - both as a custom object and as JSON. 

 

If I take the custom object or the JSON and post it through Postman, it works.

 

I added the "Content-Type: application/json" to the header, even though it is specified in the action - just as a test. Whether I include it or not, results in the same error.

 

Under advanced I both enabled and disabled "encode request body" - just because. Same error.

 

mmonline_0-1686247501420.png

 

Any ideas what else to try?

 

Thanks.

 

I have the same question (0)
  • Srini007 Profile Picture
    3,490 Super User 2026 Season 1 on at

    Hi @mmonline 

     

    You can try below checks

     

    1) As you are passing the data through variables, so can you check that the data passing is correct?

    2) As the timeout value is by default 30 seconds, if you are passing a large file, maybe it will take some time, so can you increase the timeout limit?

     

    If you find this reply helpful, please consider giving it a LIKE AND

    If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION

     

    Thanks,

    Srini

  • mwd86 Profile Picture
    100 on at

    can you post the error message? not only the statuscode.

  • mmonline Profile Picture
    169 on at

    This is the web service response:

    {"status":400,"error":"Bad Request"}

     

    The status code just shows 400.

     

    The Headers returned are:

    mmonline_0-1686579086049.png

     

    Is there a place to get addition information on the error?

     

    Thanks.

  • mmonline Profile Picture
    169 on at

    To provide a bit more context:

     

    I build the JSON to submit to the API in Power Automate. If I take either the JSON or the text output of a custom object and submit it via Postman, it works fine.

     

    Also, if I take JSON I from Postman - that I know works - and set it directly in a variable in Power Automate, it returns the same error.

     

    It seems like the "Bad Request" is not the JSON itself.

  • Verified answer
    mwd86 Profile Picture
    100 on at

    Do you run Postman locally or via www.postman.com?
    if it is running locally, power automate may not be able to access it over the internet. 

    can you try it with the settings on the image? So under advanced turn off everything except "Delete cookies" and remove everything from the custom header except the one on the pictureiws1.pngiws2.png

  • mmonline Profile Picture
    169 on at

    Thank you!!!!

     

    This worked with a couple caveats...

     

    When I pass it the JSON, it works. If I pass the custom object, it does not.

     

    I create the JSON in a variable - and that JSON did not work. However, I then convert that to a custom object and then immediately convert it back to JSON from the custom object. That seems to clean up any anomalies present in the JSON as laid out in the variable. 

     

    Oddly - that JSON variable - prior to being converted, works in Postman. 

     

    About postman - your previous question: I'm using Postman.com  - not something on the desktop. It is not integrated with PAD in anyway. I simply use it to manually test API connectivity. 

     

    I just tested this with a couple other POST to the same API and they all seem to work fine. Now I get to show the client a working process - so, again, thank you!!

  • mwd86 Profile Picture
    100 on at

    interesting case, but I guess you can't provide us the json data here or?

    maybe with modified data?

  • mmonline Profile Picture
    169 on at

    This is how I built the variable in Power Automate.

     

    I build the dispatch_lines objects in a loop and then, once that loops is complete, set a variable, "DispatchOrder" using the code below.

     

    {
     "dispatch": 
     {
     "order_id":"%CurrentOrder['id']%",
     "comments": "Your order has been received for processing by Zero G",
     "dispatch_lines":[
     %DispatchLines%
     ]
     }
    }

     

    I suppose I could do it without the formatting. 

     

    The code does have spaces, so I am going to build it without the spaces. It is more readable with the formatting.

    Ultimately, converting it to an object and back to JSON solves another issue. When I am building the dispatch_lines, I'm using the Append line to text action.

    This is the line, created in a Set Variable action.

    {"sku": "%CurrentLine.sku%", "quantity": %CurrentLine.quantity%},

     

    The final dispatch line ends up having a trailing comma - which I could remove. But, again, converting to an object and back to JSON removes it.

     

    I could have to add another action to remove the trailing comma.

     

    When I convert to object and back to JSON, it ends up like this:

    {"dispatch":{"order_id":"or_########","comments":"Comment for the order","dispatch_lines":[{"sku":"LYR-01","quantity":2.0}]}}

     

    However, if I create that as a variable and pass it to the API, it fails with a "Bad Request". If I convert that to an object and back to JSON it works.

     

    If I take the same and post it via Postman.com, it works.

  • mwd86 Profile Picture
    100 on at

    You can create a custom object directly with „set variable“

    put %at the beginning and the end of your json string   

    for example :  %{“key1“: “value1“,….}%

     

    This will directly create a custom object which you can directly convert to a json.

  • mmonline Profile Picture
    169 on at

    How do I reference the variables inside the

    %{"key": variable, "key": variable}% 

     

    I'm getting a syntax error. How do I reference "CurrentOrder["id"]"

    %{'dispatch': 
     {
     'order_id': CurrentOrder['id'],
     'comments': 'Your order has been received for processing by Zero G',
     'dispatch_lines': [
     DispatchLines
     ]
     }
    }%

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 247 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 164 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 138 Super User 2026 Season 2

Last 30 days Overall leaderboard