Skip to main content
Community site session details

Community site session details

Session Id : 2T0CPg8KtUogGtw7dxqmIL
Power Automate - General Discussion
Answered

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

Like (0) ShareShare
ReportReport
Posted on 10 Jul 2023 08:36:35 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

  • Aakash_Rajput Profile Picture
    7 on 10 Jul 2023 at 13:49:43
    Re: Multipart file upload to Third party failing with 415 when passing variable having complete syntax of json body for HTTP Body

    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

  • Verified answer
    sandeepstw Profile Picture
    302 Moderator on 10 Jul 2023 at 09:02:55
    Re: Multipart file upload to Third party failing with 415 when passing variable having complete syntax of json body for HTTP Body

    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 

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete