Retrieving Comment body and Comment Author from webhook data

Pablo Serra June 28, 2021

Hello,

I'm trying to configure a set of automation rules to keep synchronized issues between 2 cloud instances. 

One of my goals is to retrieve a comment body and a comment author from a webhook payload. I've tried {{webhookData.comment.body}} and {{webhookData.comment.author.displayName}} without any luck.

At the moment I'm only trying to log the data on the receiving instance's rule:

Aut1.pngAut2.png

Any help on these will be much appreciated.

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 9, 2021

Hello @Pablo Serra ,

Not knowing how you have configured the "source" rule (the one triggered on issue commented event) I cannot say much on why you get an empty body.

However, I have tried to do something similar on my end, and I can actually get the right values in the request body by doing the following:

Automation-Rule-On-Issue-Commented.jpg

 

By configuring the source rule as above, I get the below payload when adding a comment to an issue in the specific project:

{
  comment: {
    "id" : "10533"
    "body" : "TEST COMMENT - SOME RANDOM TEXT"
    "author" {
      "accountId" : "557XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX24c"
      "displayName": "Dario B"
    }

  }

}

 

You will then be able to access the different valued from the above body by using:

  •  {{webhookData.comment.id}} 
  • {{webhookData.comment.body}}
  • {{webhookData.comment.author.displayName}}
  • {{webhookData.comment.author.accountId}}

 

You can off course further customize the body to be sent in order to include other properties like the issue key or id and any other information you desire to receive.

 

Please test this and let me know if it helps.

 

 

Cheers,
Dario

Anastasia Pokrovskaya August 30, 2021

Hi Dario!

 

Trying to do the same, but on the Server version:

 

{
comment: {
"id" : "{{comment.last.id}}"
"body" : "{{comment.last.body}}"
"author" {
"accountId" : "{{comment.last.author}}"
"displayName": "{{comment.last.author.displayName}}"
}

}

}

 

Receiving 500-th error with such context :

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>500</status-code><message>Unexpected character ('c' (code 99)): was expecting double-quote to start field name at [Source: org.apache.catalina.connector.CoyoteInputStream@4e98ea29; line: 2, column: 6]

 

If it's edited in this way

{
"issue.last.comment": {
"id" : "{{comment.last.id}}"
"body" : "{{comment.last.body}}"
"author" {
"accountId" : "{{comment.last.author}}"
"displayName": "{{comment.last.author.displayName}}"
}

}

}

 

I receive such code:

Unexpected character ('"' (code 34)): was expecting comma to separate OBJECT entries at [Source: org.apache.catalina.connector.CoyoteInputStream@26ab28e4; line: 4, column: 6]

Can you help me to understand this issue? 

 

Thanks in advice

Anastasia.

 

 

Not actual - solved

Like Dario B likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events