Unexpected Character thrown when trying to perform REST calls
プラットフォームについて: Cloud と Data Center - この記事は クラウド プラットフォームとデータセンター プラットフォームの両方に等しく当てはまります。
Server* 製品のサポートは 2024 年 2 月 15 日に終了しました。Server 製品を実行している場合は、 アトラシアン Server サポート終了 のお知らせにアクセスして、移行オプションを確認してください。
*Fisheye および Crucible は除く
問題
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/issueYou 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]"
]
}原因
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/issueNote 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
ソリューション
Refer to Jira REST APIs and make sure the correct formatting is used
この内容はお役に立ちましたか?