{"errorMessages":["Unexpected character (''' (code 39)): expected a valid value

AskMe picture AskMe · Jul 19, 2015 · Viewed 21.1k times · Source

I found "Query using POST" from here.

And tried to use curl command from command like. Installed curl by refering this for windows.

Here is my CURL string:

curl -D- -u admin:password -X POST -H "Content-Type: application/json" --data 
'{"jql":"project = CI","startAt":0,"maxResults":50,"fields":["summary","status","assignee"]}' 
"https://myclientname.atlassian.net/rest/api/2/search"

This is how I'm doing and getting error:

{"errorMessages":["Unexpected character (''' (code 39)): expected a valid value
(number, String, array, object, 'true', 'false' or 'null')\n
at [Source: org.apache.catalina.connector.CoyoteInputStream@1626cb2; line: 1, column: 2]"]}

Is there any problem making this curl string in windows? Please suggest? How can I correct this and get JSON object? Please note that, userID, password and client name is correct. Thanks.

Answer

Peter Kennedy picture Peter Kennedy · Sep 30, 2016

Seems to be an windows issue. Do not use the ' (single-quote) character.

Instead, use " (double-quote) character for enclosing the string. Then, if you have inner quotes, use """ (3x double-quotes) to escape them.

Example: "{ """name""":"""Frodo""", """age""":123 }"