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 / 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.
I have the same question (0)
  • 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

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard