cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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

I found the solution here 

View solution in original post

4 REPLIES 4
SamPo
Impactful Individual
Impactful Individual

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 

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

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

I found the solution here 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (3,273)