Not able to comment jira ticket using json generated by shell script

Rasmi Ranjan Sahu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2024

Hi 

 

I am trying to add a comment to jira ticket using rest api 2

I tried to manually create json file by referring to jira developer site but while creating a json file using shell script getting error below

{"errorMessages":["Illegal unquoted character ((CTRL-CHAR, code 9)): has to be escaped using backslash to be included in string value\n at

 

I do not know where the problem with the Json is below

{"body": "
........................................
MEMORY UTILIZATION

Total Memory : MB
Available Memory : MB
Buffer+Cache Memory : MB
Free Memory : MB
Used Memory : MB
Memory Usage Percentage : %

MEMORY OK
........................................
........................................
CPU UTILIZATION

Number of Cores :4

Total CPU Load Average for the past 15 minutes :0.53,

CPU Usage % :76.90
........................................

end

"
}

 

If I add the same content to manually created json file it perfectly works. 

1 answer

0 votes
Radek Dostál
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.
April 25, 2024

Well, because you're pasting this in console right? The only thing the console sees is end of line, making that json invalid/broken/partial. What the message suggests is that you need to escape end of line if you want to include multi-line string. In bash, that would look like

{"body": "something \
multiline"}

And as the end of line is escaped, shell will interpret the multiline text properly.

 

All in all though you would probably be better off reading the json from file, rather than pasting it into a shell command directly.

Suggest an answer

Log in or Sign up to answer