How to send multipart/form-data with PowerShell Invoke-RestMethod

后端 未结 3 1698
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 13:18

I\'m trying to send a file via Invoke-RestMethod in a similar context as curl with the -F switch.

Curl Example

curl -F FileName=@\"/path-to-file.na         


        
3条回答
  •  鱼传尺愫
    2020-11-28 13:58

    The problem here was what the API required some additional parameters. Initial request required some parameters to accept raw content and specify filename/size. After setting that and getting back proper link to submit, I was able to use:

    Invoke-RestMethod -Uri $uri -Method Post -InFile $filePath -ContentType "multipart/form-data"
    

提交回复
热议问题