cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
SamPo Impactful Individual
Impactful Individual

Format HTTP request body

Hi,

 

I have an HTTP request where the body is raw text (the purpose is to create a file to upload via API)

In postman the request works fine but in flow the exact same calls fails. This seems to only be due to the formatting of the 'body' text as I've done the following test:

 

1) Run call in Postman successfully

2) Copy body from PM to Flow

3) Copy body back from Flow to PM

4) PM call fails (on the face of it the text is exactly the same, even checked with a code difference checker)

 

2019-03-31_1446.png

 

Anyone have any ideas how to correctly format in Flows? I've tried converting to string, using it in a variable etc but all with no success.

 

Thanks

Sam

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SamPo Impactful Individual
Impactful Individual

Re: Format HTTP request body

I found the solution here 

View solution in original post

4 REPLIES 4
SamPo Impactful Individual
Impactful Individual

Re: Format HTTP request body

It seems flow does not know how to read the multipart text.

I decided to create an additional test flow that receives HTTP requests so I can call it both from Postman and from my flow and see the difference.

 

When receiving the request from Postman the body is converted to the following:

 

{
  "$content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  "$content": "LS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5N01BNFlXeGtUclp1MGdXDQpDb250ZW50LURpc3Bvc2l0aW9uOiBmb3JtLWRhdGE7IG5hbWU9ImZpbGUiOyBmaWxlbmFtZT0ibmV3LWFnZW50MTIzLnR4dCINCg0KdGVzdDEyMw0KDQotLS0tLS1XZWJLaXRGb3JtQm91bmRhcnk3TUE0WVd4a1RyWnUwZ1ctLQ==",
  "$multipart": [
    {
      "headers": {
        "Content-Disposition": "form-data; name=\"file\"; filename=\"new-agent123.txt\""
      },
      "body": {
        "$content-type": "application/octet-stream",
        "$content": "dGVzdDEyMw0K"
      }
    }
  ]
}

When sending the same call from Flow it is received as follows:

{
  "$content-type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  "$content": "LS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5N01BNFlXeGtUclp1MGdXCkNvbnRlbnQtRGlzcG9zaXRpb246IGZvcm0tZGF0YTsgbmFtZT0iZmlsZSI7IGZpbGVuYW1lPSJuZXctYWdlbnQxMjMudHh0IgoKdGVzdDEyMwoKLS0tLS0tV2ViS2l0Rm9ybUJvdW5kYXJ5N01BNFlXeGtUclp1MGdXLS0="
}

Flow just converts the whole body to base64 and doesn't break down the multipart values.

Any ideas on how to do this via Flow?

 

I've found the following realted post http://johnliu.net/blog/2017/7/building-non-json-webservices-with-flow but need some more help here on exactly how to go about doing this.

 

Sam 

Community Support
Community Support

Re: Format HTTP request body

Hi @SamPo ,

 

You could refer to the method mentioned in the blog.

However, the trigger may need to use When a HTTP request is received, Request trigger has been changed.

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SamPo Impactful Individual
Impactful Individual

Re: Format HTTP request body

I've already had a look at that post but it's not clear to me exactly what I need to do.

I have no experience working with swagger/OpenAPI, if you could provide me with some clear guidence on this that would be much appreciated.

 

Thanks

SamPo Impactful Individual
Impactful Individual

Re: Format HTTP request body

I found the solution here 

View solution in original post

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,606)