Unexpected Character thrown when trying to perform REST calls

Still need help?

The Atlassian Community is here for you.

Ask the community

 

Platform Notice: Server, Data Center, and Cloud By Request - This article was written for the Atlassian server and data center platforms but may also be useful for Atlassian Cloud customers. If completing instructions in this article would help you, please contact Atlassian Support and mention it.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

 

Problem

When trying to use REST API, you receive an Unexpected Character error message. For example, when using the follow curl command to create a new JIRA issue via REST

curl -u admin:admin -X POST --data /home/user/data.txt -H "Content-Type: application/json" http://localhost:8080/rest/api/2/issue

You receive the following error response

{  
   "errorMessages":[  
      "Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)\n at [Source: org.apache.catalina.connector.CoyoteInputStream@49d0d945; line: 1, column: 2]"
   ]
}

Cause

The format of the command is incorrect. In this example, the format for --data is incorrect. It should be the following

curl -u admin:admin -X POST --data @/home/user/data.txt -H "Content-Type: application/json" http://localhost:8080/rest/api/2/issue

Note that there is an additional alias (@) before the file path. In this case, it was expecting an '@' but got a '/' instead, hence throwing the error

Resolution

Refer to JIRA REST APIs and make sure the correct formatting is used
Last modified on Mar 30, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.