Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't add comment via rest on

aas
Contributor
July 22, 2020 edited

Hello!

I try to add comment via rest, but can add it only if body is latin. If body is not latin I have 400 and errorMessages":["Invalid UTF-8 start byte 0xfb\n at [Source: org.apache.catalina.connector.CoyoteInputStream@355b26b7; line: 1, column: 42]"]}

I try to set encoding=utf-8 but have no luck

Here is my request

curl -i -u "user:password" -H "Content-type: application/json; charset=utf-8" -H "Accept: application/json" -d"{\"body\":\"абвгд\"}" -X POST https://jiratest/rest/api/latest/issue/issueKey/comment 

 

1 answer

1 accepted

0 votes
Answer accepted
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 23, 2020 edited

Try charset=ISO-8859-1 first.

If that doesn't work, you may have to pre-convert all the special characters in the body text into their UTF-8 codes before submitting it, such as:

{ body : "\u1072\u1073\u1074\u1075\u1076" }

 

aas
Contributor
July 24, 2020

@David Bakkers thanks for help. I found out that if you run curl in cmd, then the -d argument parameter has the same encoding as the Windows console - CP866. Even if you set -H "Content-type: application/json; charset=utf-8". So I've execute curl command from linux and everything is fine. 

But if you need run it in windows workaroud is saving json in a file in utf-8 encoding and passing the request body like this:

curl -X POST -i -H "Content-type: application/json; charset=utf-8" -d @C:\request_body.json
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2020

Glad to hear you worked it out, and that there is difference to how curl does encoding in Windows vs Linux.

Suggest an answer

Log in or Sign up to answer