Unexpected Character thrown when trying to perform REST calls

Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.

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

1 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

1 2 3 4 5 { "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

1 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

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.