I am trying to invoke a curl command in powershell and pass some JSON information.
Here is my command:
curl -X POST -u username:password -H "Content-Type: application/json" -d "{ "fields": { "project": { "key": "key" }, "summary": "summary", "description": "description - here", "type": { "name": "Task" }}}"
I was getting globbing errors and "unmatched braces" and host could not be resolved, etc.
Then I tried prefixing the double quotes in the string with the backtick character, but it could not recognize the -
character in the description json field
thanks
EDIT 1:
When I wrote the curl command in a regular batch file, I used double quotes and no single quotes. Also, in the -d
string, I escaped all the double quotes with \
and the command worked.
In this case, my curl
is actually pointing to curl.exe. I specified the path, just didn't list it here. Also I tried adding single quotes around -d
and I got:
curl: option -: is unknown curl: try 'curl --help' or 'curl --manual' for more information
Seems like it cannot recognize the -
character in the JSON
-d
argument in single quotes instead of double 2) Make surecurl.exe
is actually being called. If I remember correctlycurl
in powershell can be an alias forInvoke-WebRequest
– Buoyancycurl.exe -X POST "https://reqbin.com/echo/post/json" -H "Content-Type: application/json" -d (@{fields=@{project=@{key='key';summary='summary';description='description - here'; type=@{name='Task'}}}} | ConvertTo-Json -Depth 3 -Compress)
would apply ? – Iquique