Posting external link as comment to Jira using Node.js

greg chap November 3, 2019

I am posting a comment with some text and external link combined as string using jira rest api(v3). Looks like below

 

"text [test|https://www.test.com]"

 

Comment shows up as normal text without external link on the jira issue. Because it adds a backslash before the first square bracket. Even though it looks correct on jira ticket, as soon as I select Edit on the comment, i see

text \[test|https://www.test.com]

so I tried unicode for the square bracket and posted comment like below

text [test|https://test.com]

It shows correctly as comment, but again without the external link. I tried adding couple of \ before the first square bracket, I tried double square brackets around the external link as well, but no luck.

I am following the documentation for adding comment right below

Basically my request is as below

var bodyData = `{
  "visibility": {
    "type": "role",
    "value": "Administrators"
  },
  "body": {
    "type": "doc",
    "version": 1,
    "content": [
      {
        "type": "paragraph",
        "content": [
          {
            "text": "text [test|https://www.test.com]",
            "type": "text"
          }
        ]
      }
    ]
  }
}`;

var options = {   method: 'POST',   url: '/rest/api/3/issue/{issueIdOrKey}/comment',   auth: { username: 'email@example.com', password: '<api_token>' },   headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
   },   body: bodyData};request(options, function (error, response, body) {
   if (error) throw new Error(error);   console.log(
      'Response: ' + response.statusCode + ' ' + response.statusMessage
   );   console.log(body);
});

Any thoughts on what I am missing?

Edit 1:

==========
It's been few days, would really appreciate some one look at this issue. Added couple of tags> jira-service-desk, jira-service-desk-development. 

0 answers

Suggest an answer

Log in or Sign up to answer