I want to do the following call in a powershell script file:
Invoke-WebRequest -UseBasicParsing -Uri https://myservice.com `
-ContentType application/json -Method POST `
-Body '{"jsonproperty1": 200, "jsonproperty2": 1}'
This script works perfectly fine when executed in a powershell. However when I try to run it as:
powershell -C 'Invoke-WebRequest -UseBasicParsing -Uri https://myservice.com -ContentType application/json -Method POST -Body '{"jsonproperty1": 200, "jsonproperty2": 1}''
I can't seem to get it to work. I saw this question, but the answer there doesnt work in my case.
I have tried all possible combinations of '
, "
and `
,using different escaping techniques, that I can think of. But I keep getting 400 Bad Request from my API, which I assume is because the jsonbody cant be serialized.