rest - How to convert this cURL request to powershell script? -
here's curl request should work according example in api's documentation:
curl -x post -f "url=http://example.com/myjs.min.js" -f "file=@c:\website\js\myjs.min.js" https://restapi/endpoint
this i've tried didn't work (--> 400 bad request):
$uri = 'https://restapi/endpoint' $file = get-item c:\website\js\myjs.min.js $body = @{ url = 'http://example.com/myjs.min.js' file = $file } invoke-restmethod -method post -uri $uri -body $body
what missing/doing wrong here? i'm assuming it's part assign file $body
don't know how should fixed.
edit
changed $file = get-content c:\website\js\myjs.min.js -raw
but still doesn't work. took little closer response server , says following:
no file present, please ensure file posted parameter name "file".
but "file" set in body, why complaining?
Comments
Post a Comment