Hello,
Need to add the SQL output generated in the codeblock of the comments section, below is the command im using.
curl -D- -u $uname:$token -X POST --data @/tmp/a.json -H "Content-Type: application/json" https://abc.atlassian.net/rest/api/3/issue/abc-34716/comment
Error:
{"errorMessages":[],"errors":{"comment":"Comment body can not be empty!"}}
a.json:
{
"type": "codeBlock",
"attrs": {
"language": "javascript"
},
"content": [
{
"type": "text",
"text": "var foo = {};\nvar bar = [];"
}
]
}
Hello @Vineet Bansal ,
As a referance point the Add comment syntax can be seen here:
Then the error you noted is indicating that the "Body" section is missing,
{"errorMessages":[],"errors":{"comment":"Comment body can not be empty!"}}
Try updating the syntax in your a.json to the following and you should be all set:
{
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type":"codeBlock",
"attrs":{
"language":"java"
},
"content":[
{
"type":"text",
"text":"var foo = {};\nvar bar = [];"
}
]
}
]
}
}
It will show up in the comment like this:
Also a really good tip for rapid formatting troubleshooting in comments like this is to add the desired formatting you are trying to troubleshoot, on a test comment from the UI front end, then do a Get comments via GET /rest/api/3/issue/{issueIdOrKey}/comment on the endpoint to see the formatting in action when done system side.
As an exe if you wanted to add in some additional text like the following screenshot:
Run a get on the issue and you will see the additional formatting as:
{
"body": {
"version": 1,
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "SOME TEXT"
}
]
},
{
"type": "codeBlock",
"attrs": {
"language": "java"
},
"content": [
{
"type": "text",
"text": "var foo = {}; var bar = [];"
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Additional text with bullet points:"
}
]
},
{
"type": "bulletList",
"content": [
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "1"
}
]
}
]
},
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "2"
}
]
}
]
},
{
"type": "listItem",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "3"
}
]
}
]
}
]
}
]
}
}
Regards,
Earl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another related quick question, can we add value from a variable in the text, like this
"text":"$result" ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.