Forums

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

Jira Automation: How to send new comment via Web Request on Issue Commented

Alexander Tesch September 12, 2023

Hi everyone,

I have two projects A and B. When a new comment is created in A, I want that new comment to show up in a specific issue in project B. For that, I have already set up a rule with the trigger "Issue Commented" and following the action "Web Request" where I just want to send that new comment to project B. 

And I just don't know how to formulate the custom data for the POST. Currently I have:

{
"body": "{{triggerIssue.comment.body}}"
}

but I only get the error message: {"errorMessages":[],"errors":{"comment":"Comment body is not valid!"}}

I also tried multiple other versions that also don't work.. So, I need some help here.. Does anybody know how to do it properly?

Thanks in advance!

Best,

2 answers

1 accepted

1 vote
Answer accepted
Marios Marneros
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.
September 12, 2023

Hey @Alexander Tesch , welcome to the Atlassian Community. The request body format depends on the version of the API you use. For v3 you will have to send the comment in Atlassian Document Format. The documentation for adding a comment using v3 can be found here.

When using v2 of the Jira API, you will have to post the body as text, the same way as in the above request. The documentation for adding a comment using v2 can be found here.

Let me know if that helps!

Alexander Tesch September 12, 2023

Thanks for your replies!

Right, that's what I was also trying, but I don't seem to get it right in the custom data of my POST web request (v3):

{
"body": {
{{triggerIssue.comment.body}}
}
}

 What am I missing?

Marios Marneros
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.
September 12, 2023

You want to use the example below for v3:

"body": {

  "content": [

    {

      "content": [

        {

          "text": "{{triggerIssue.comment.body}}",

          "type": "text"

        }

      ],

      "type": "paragraph"

    }

  ],

  "type": "doc",

  "version": 1

}

V2 is much easier as you can post the body as text

{
"body": "{{triggerIssue.comment.body}}"
}
Like Alexander Tesch likes this
Alexander Tesch September 12, 2023

with the additional curly brackets { } encompassing the whole body object, it works now. Awesome! Thank you so much Marios! :)

Like Marios Marneros likes this
0 votes
Evgenii
Community Champion
September 12, 2023

Hi, @Alexander Tesch 

One question - is there a reason to use such workaround with webhooks?

If target issue is issue in the same instance, you can look for it with Automation action, and change it's description through Automation.

Alexander Tesch September 12, 2023

Yes, these two projects are in separate instances, so we need web requests as far as I know.

Dima Astahov
Contributor
March 5, 2024

Thanks all for info. I'm new in this thread with similar problem, anybody can point me in what place we  create body for POST, in my case I'm using ISSUE DATA (Automation format) in drop down ? where I need to go to check all those fields ?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events