Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 650
AskMe Avatar asked Jul 19 '15 17:07

AskMe


2 Answers

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 }"

like image 81
Peter Kennedy Avatar answered Oct 26 '22 12:10

Peter Kennedy


I tried the cURL you pointed to in your question, but with no luck. Also, the cURL comes with Git is not working either. However, the one I installed with CygWin works. And the same command is also working in Ubuntu. Which basically indicates that your command itself is OK.

If you are working on Windows, I recommend you to use a tool called Fiddler. It can perform almost all HTTP requests you may need. Good luck!

Update: Here I add the steps to make HTTP POST request with Fiddler.

1) After starting Fiddler, you will see the GUI like Figure 1. The upper right panel is where you should input staff like JIRA's website, request type, and the content you want to post. To be specific, under the "Composer" tab, you need to select "POST" as your request type, and put the JIRA's URL there, keep HTTP/1.1 selected. You should put the request header under the URL bar. Now, you need to pay attention to. At least, you should input two things in HTTP header: the content type, which is "application/json", and the authorization header. The authentication is a Base64 string, you can get your Base64 string here with your "admin:password". If you want to know more about the basic authentication method, please refer Jira's website here. The lower right panel of the GUI is where you should put your post content. enter image description here

2) When you get these staff ready, you can click the "Execute" button at upper right corner of the GUI. The execution result will be shown at the left panel. As Figure 2 shows, if you get a result with the status 200, congratulations, you got it. If you get other types of results, please google the error code or leave comments here. enter image description here

3) Double click the result, the returned JSON content will be shown in the lower right panel like Figure 3. You can try different tab to see the returned staff. For example, if you go to the "TextView", you will get the returned JSON as pure string. enter image description here

Please comment if you have any further question.

like image 43
Chong Tang Avatar answered Oct 26 '22 13:10

Chong Tang