I have a unix cmd that I need to rewrite to achieve the same result in Windows PowerShell. I am specifically stuck on the login...
Original Unix Command:
curl -u user:xxxx -X POST -s --data '{"one" : "one/text","two" : "two/text"}', http://myurl.net/run
My Attempted Conversion:
$params = '{"one" : "one/text","two" : "two/text"}'
Invoke-WebRequest -Uri http://myurl.net/run -Credential user:xxxx -Method POST -Body $params
Right now, I get the error:
Invoke-WebRequest : {"mimetype":[{"stderr":"text/plain"}],"streamdata":[{"stderr":"User cannot be authenticated"}],"status":"error"}
Thank you for any pointers or help!!
Bodycan take ahashtableso manually forming your own JSON is unnecessary. What you're getting, however, is an authentication error. Does your endpoint expect header authentication of some kind?