Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to identify which Issue is updated from Attachment?

I have an integration setup between Servicenow and JIRA using webhook. So when an attachment is added to the Issue is JIRA, two webhook events are triggered: “attachment_created” and “comment_created”.
However if we check the “attachment_created” JSON body which is sent over to Servicenow, we are not able to identify which issue in Jira was updated. Here is the JSON body which is sent over to Servicenow:

{"timestamp":1639107865465,"webhookEvent":"attachment_created","attachment":{"self":"https://hazletttest.atlassian.net/rest/api/2/attachment/28271","id":"28271","filename":"Test document (87b03c0b-5773-4627-841d-86f919aca5e7).txt","author":{"self":"https://hazletttest.atlassian.net/rest/api/2/user?accountId=60f18969a2243e0070571395","accountId":"60f18969a2243e0070571395","avatarUrls":{"48x48":"https://secure.gravatar.com/avatar/6aefe780d760cba5d8c69aa1c622d85d?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FAB-6.png","24x24":"https://secure.gravatar.com/avatar/6aefe780d760cba5d8c69aa1c622d85d?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FAB-6.png","16x16":"https://secure.gravatar.com/avatar/6aefe780d760cba5d8c69aa1c622d85d?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FAB-6.png","32x32":"https://secure.gravatar.com/avatar/6aefe780d760cba5d8c69aa1c622d85d?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FAB-6.png"},"displayName":"Aniket Bhanse","active":true,"timeZone":"America/New_York","accountType":"atlassian"},"created":"2021-12-09T22:44:25.465-0500","size":42,"mimeType":"text/plain","content":"https://hazletttest.atlassian.net/secure/attachment/28271/Test+document+%2887b03c0b-5773-4627-841d-86f919aca5e7%29.txt"}}

Can we update the JSON body so that it sends over the issue number/issue ID as well? Or how will we identify which issue was updated in JIRA? Any suggestions?

 

1 answer

0 votes
Andy Heinzer Atlassian Team Dec 17, 2021

Hi Aniket,

I can see that it appears someone else from your site created a support case for this same issue.  Below is a response from my colleague, Russ, that I hope that this response will help other users that might come across this problem as well:

The attachment created event webhook payload does not currently contain the issue key where the attachment was created. Including the issue key in the attachment created webhook payload has been requested in the past, however that request was closed due to lack of interest.

There are a couple ways you can surface the issue key in a webhook and associate it with an attachment. As mentioned on the feature request above, you can use {issue.key} or {issue.id} query parameter value in the webhook URL as described in https://developer.atlassian.com/server/jira/platform/webhooks/#variable-substitution-in-the-webhook-url

Alternatively, you can use the issue updated event rather than the attachment created event in the webhook configuration. This will produce a webhook JSON payload containing the full details of the issue at the time of the update which will include the issue key as well as additional details of all the fields associated with the issue, including attachments. It will also include a changelog entry as below which contains the details of the added attachment.

  "changelog": {
    "id": "15995",
    "items": [
      {
        "field": "Attachment",
        "fieldtype": "jira",
        "fieldId": "attachment",
        "from": null,
        "fromString": null,
        "to": "10036",
        "toString": "Sample.pdf"
      }
    ]
  }
}

Note that this approach will likely require custom parsing of the webhook content on the ServiceNow side in order to pull out the issue key, attachment ID, and attachment content URL.

I also ran across this ServiceNow community post that may provide some additional guidance on how to copy attachments between Jira and ServiceNow.

I hope this helps.

Andy

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Jira Software

👋 Looking for 15-20 volunteers to test Atlassian training content

Hi everyone! Are you interested in beta testing Atlassian University’s newest (unreleased!) training course? We’re looking for 15-20 volunteers to test our newest training course, Basic reporting...

595 views 21 25
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you