cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamPo
Power Participant
Power Participant

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
Power Participant
Power Participant

I found the solution here 

View solution in original post

4 REPLIES 4
SamPo
Power Participant
Power Participant

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.

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
Power Participant
Power Participant

I found the solution here 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (4,902)