web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / HTTP Post multipart/fo...
Power Automate
Unanswered

HTTP Post multipart/form-data

(0) ShareShare
ReportReport
Posted on by 29

Hi,

 

I am trying to post SharePoint files to a 3rd party via their API.  Their API uses multipart/form-data.  After some trial and error, I can POSTcontent, but only text files come out correctly on the destination.  Other files (Excel, Word, jpg, etc.) post, but the data is not readable. What do I need to do to the file content to format it properly?

 

Thanks!

 

http post.png

 

Categories:
I have the same question (0)
  • v-yuazh-msft Profile Picture
    on at

    Hi @JonathanM,

     

    The file content is with type base 64 when the files with type Excel, Word, jpg, etc.

     

    Best regards,

    Alice

  • JonathanM Profile Picture
    29 on at

    Thanks Alice.  I've tried converting the content a variety of ways, but have not been able to get it converted properly.  What should the formula be to convert the file content?

     

    Thanks,

     

    Jonathan

  • Community Power Platform Member Profile Picture
    on at

    @JonathanM Did you ever resolve this issue?

    How were you able to post text files using this method in the first place? Everthing I try just converts the whole string to base64 and flow completely ignores the multipart sections.

    I'm trying to do it now through swagger but still no luck yet.

    Any updates you have here would be much appreciated.

     

    Thanks,

    Sam

  • JonathanM Profile Picture
    29 on at

    Hi @Anonymous 

     

    This worked for me for any type of content (text, Word, Excel, etc.)

    2019-04-02_08h15_42.png

  • Community Power Platform Member Profile Picture
    on at

    @JonathanM Thanks for this.

    Unfortunately it's not working for me. I'm posting to the API for Atlassian Jira Cloud.

    It responds with a code of 200 but no file is actually created.

     

    2019-04-02_1817.png

  • Community Power Platform Member Profile Picture
    on at

    I got it working in the end. I had to specifically define the content type in the body

    Screenshot 2019-04-02 at 22.10.53.png

  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    @JonathanMor @Anonymous  Do you know how to modify the request body to include other parameters in the multi-part form? Your examples appear just to have a single part, which is the file itself.

  • Community Power Platform Member Profile Picture
    on at

    @WillPage  What else are you trying to update?

     

    Also are you able to make the call you wish from Postman? I used postman calls to a test flow I built to figure out the structure I needed. Perhaps you can do the same. If you have an example of the postman call then screenshot it here as well if you can.

  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    @Anonymous  Thanks for responding.

     

    It's a file upload to Bamboo HR. They need a bit of metadata with the file; a category, which is basically the folder it goes in and whether it's shared or not. Here's their doco https://www.bamboohr.com/api/documentation/employees.php#uploadEmployeeFile

     

    It works fine in Postman, and it works fine posting plain text in the file content using the example copy-pasted in the documentation (with the category changed).

     

    I've tried using your example and adding the metatdata as extra records in the $multipart object like this

     

    {
     "$content-type": "multipart/form-data",
     "$multipart": [
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"category\""
     },
     "body": {
     "$content": "18"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"fileName\""
     },
     "body": {
     "$content": "test.bmp"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"share\""
     },
     "body": {
     "$content": "yes"
     }
     },
     {
     "headers:": {
     "Content-Disposition": "form-data; name = \"file\"; filename=\"test.bmp\""
     },
     "body": {
     "$content-type": "application/octet-stream",
     "$content": {
     "$content-type": "image/bmp",
     "$content": "iVBORw0KGgoAAA............Jggg=="
     }
     }
     }
     ]
    }

    However, I get 403 Forbidden back from the server. File category 18 is the only one I have write access to, so there's every chance the metadata isn't being sent properly and it's denying me to write whatever the default file category is.

     

    Here's the screen shot from Postman:Capture.PNG

     

  • WillPage Profile Picture
    2,307 Super User 2025 Season 2 on at

    What I pasted as the request body there was copied from the output of a failed run. I spotted that Flow is adding its own record for the body... However, it still fails with a 403:

     

    Request body as seen in the designer:

    {
     "$content-type": "multipart/form-data",
     "$multipart": [
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"category\""
     },
     "body": {
     "$content": "18"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"fileName\""
     },
     "body": {
     "$content": "test.bmp"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"share\""
     },
     "body": {
     "$content": "yes"
     }
     },
     {
     "headers:": {
     "Content-Disposition": "form-data; name = \"file\"; filename=\"test.bmp\""
     },
     "body": @{body('Get_file_content_using_path')}
     
     }
     ]
    }

    And as seen in the output of a failed run:

     

    {
     "$content-type": "multipart/form-data",
     "$multipart": [
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"category\""
     },
     "body": {
     "$content": "18"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"fileName\""
     },
     "body": {
     "$content": "test.bmp"
     }
     },
     {
     "headers": {
     "Content-Disposition": "form-data; name=\"share\""
     },
     "body": {
     "$content": "yes"
     }
     },
     {
     "headers:": {
     "Content-Disposition": "form-data; name = \"file\"; filename=\"test.bmp\""
     },
     "body": {
     "$content-type": "image/bmp",
     "$content": "iVBORw.................Jggg=="
     }
     }
     ]
    }

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard