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 / Send File via POST and...
Power Automate
Unanswered

Send File via POST and multipart / form-data

(1) ShareShare
ReportReport
Posted on by 4
I am using Power Automate Desktop to call a POST - API with accepts multipart/form-data. In the body of the requist I send various  data as string values. This data is interpreted correctly, the receiving api get the correct values.
One of the parameters I can set is a file. For this file I can also provide data, e.g. I want to upload a pdf.
If I send the filecontents as a variable, then the created file is larger than the source file, it seems as if the bytes sent are interpreted as characters. If I open both the original file and the created file in an editor, they seem to be identical, but I believe the original file to depict the bytes and the created file to be the character representation of the same bytes (and therefore the file is larger).
If I try to send it with base64 and content-transfer-encoding: base64 the created file contains the characters of the base64 representation and again is not equal to the original pdf.
If  I try to send the binary data (convert file to binary data), the created file only contains the characters bytes [number of bytes] and is very small.
What is the correct way to use multipart/form-data to create / upload the binary contents of a file?
Any help is appreciated.
  • StefanPHS Profile Picture
    4 on at
    This is part of a powershell code (7.x) , which does the same and the result is correct:
    $pair = "$($user):$($pass)"
    $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
    $basicAuthValue = "Basic $encodedCreds"
     Add-Type -AssemblyName 'System.Net.Http'
       
        $headers = @{
            "Authorization"     = $basicAuthValue
           
            "Content-Type"      = "multipart/form-data"
        }
        $form = @{
            ContentFiles      = Get-Item -Path $filePath
            ContentTypeName = "CompanyInvoiceOutgoing"
           
        }
        $Result = Invoke-WebRequest -Uri $url -Method POST -Headers $headers -Form $form
        $result
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 389

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard