I am trying to post a file to an API, which works perfectly under Linux using this curl command:
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Token foo_bar' -F content=@'Filename.ending' 'http://test.test.com/api/upload'
I don't get how to work with the 'F' Parameter in curl on the Invoke-RestMethod/Invoke-WebRequest command. I tried:
Invoke-WebRequest -Uri $URL -Headers @{Authorization = 'Token '+foo_bar} -Method POST -ContentType 'multipart/form-data'
I tried adding -F 'C:\Users\Me\Filename.ending'
to my command, I also tried using -InFile 'C:\Users\Me\Filename.ending'
, but I always get a response from the API telling me:
{"error":{"code":"GENERAL_ERROR","message":"missing uploaded file 'Filename.ending'"}}
Which probably suggests it wants the file in a different way. I also tried reading it in by Get-Content 'C:\Users\Me\Filename.ending'
but had no success. What am I missing?