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 / Multipart file upload ...
Power Automate
Answered

Multipart file upload to Third party failing with 415 when passing variable having complete syntax of json body for HTTP Body

(0) ShareShare
ReportReport
Posted on by 7

I have created a flow for retrieving html document along with metadata and some pdf attachment from a third party and then uploading the same to another third party. Data retrieval part is working fine but while uploading we are facing issues. For all this we are using HTTP connector.

 

Issue: For file upload we are using multipart, when whole body syntax is added directly to the HTTP body section it is working fine and the file gets uploaded, but when we try to create a variable and added all the multipart JSON syntax to the variable and used this variable reference in the HTTP request then we are getting 415 error.

There are multiple attachments for each document for which we need to apply a loop and append all the content to the variable and then pass it to the HTTP request. Seems like it could be due to some additional escape chars which could be added to the JSON and in HTTP request it is considered as invalid JSON, also replacing the escape charter is not making the JSON valid.

 

Kindly suggest as this is very crucial and we are very close to the deadline.

Thanks in advance,

Aakash Rajput

Categories:
I have the same question (0)
  • Verified answer
    sandeepstw Profile Picture
    312 Moderator on at

    Hi There,

     

    Instead of saving the whole HTTP request body in a variable, only store the data from the attachments in an array variable. Each item in the collection should be an object with the Content-Disposition, Content-Type, and body for each attachment. Set up a "Compose" action that lets you make the JSON string for each part. In the 'Compose' action, go through the array of files and add each one to the string. Instead of using a variable for the body in the HTTP request action, use the result of the 'Compose' action. In the HTTP request headers, don't forget to write "Content-Type: multipart/form-data; boundary=your-boundary." The limit string should be the same as the one used for the "Compose" action.

     

    Here you can see your boundary - https://stackoverflow.com/questions/3508338/what-is-the-boundary-in-multipart-form-data

     

    Make sure the format of the multipart content is right, especially the headers for each part and the structure as a whole.

     

    Please give kudos and mark as solution if it helps.  

      

    Thanks, 

    Sandeep Mishra 

     

  • Aakash_Rajput Profile Picture
    7 on at

    Hi Sandeep,

     

    Thank you so much for your quick response.

    Your suggestion helped me in fixing the issue and now the flow is working like a charm.

    Based on your suggestion I have made the below changes to my steps:
    - Instead of passing the variable in HTTP body I have created a compose object for each item.

    - Converted compose string to Json. 
    - Appended all the items in Array.
    - Passed the final array in the multipart body.

    Aakash_Rajput_0-1688996627608.png

    And below is the HTTP body.

    Aakash_Rajput_1-1688996694345.png

     

    Thanks,

    Aakash Rajput

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard