The -f
switch in cUrl
is used for a multi-part formdata
content type. PowerShell fortunately natively supports it, here's a generic example to get you started.
$Uri = 'https://api.contoso.com/v2/profile'
$Form = @{
firstName = 'John'
lastName = 'Doe'
email = 'john.doe@contoso.com'
avatar = Get-Item -Path 'c:\Pictures\jdoe.png'
birthday = '1980-10-15'
hobbies = 'Hiking','Fishing','Jogging'
}
$Result = Invoke-WebRequest -Uri $Uri -Method Post -Form $Form
And for your specific scenario, something like this should get you moving in the right direction.
$url = 'https://url/api'
$Form = @{
json = Get-Content .\test.json
file = Get-Content .\test.txt
}
$Result = Invoke-WebRequest -Uri $Uri -Method Post -Form $Form -Token "mkey"