Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to find the exact Jira Issue related to attachment via API

dkatrandzhiev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Nov 08, 2023

We use Jira Webhooks to send issue-related data when an event occurs.

The problem is that in the 'attachment_created' webhook event JSON we receive, there is no information about the issue. I

s there any way to find the exact issue ID when you receive 'attachment_created' data, apart from querying and crawling all issues?

 

The actual webhook data!

We are recieving the same data when we try it using the API using https://myJira.atlassian.net/rest/api/2/attachment/10003

Why everything in Jira is so messed up...

{
  "timestamp": 1699047222230,
  "webhookEvent": "attachment_created",
  "attachment": {
    "self": "https://myJira.atlassian.net/rest/api/2/attachment/10003",
    "id": "10003",
    "filename": "cisco_switch.jpeg",
    "author": {
      "self": "https://myJira.atlassian.net/rest/api/2/user?accountId=712020%3Af5defdeb-2e9d-4316-86f0-191123ae80ed",
      "accountId": "712020:f5defdeb-2e9d-4316-86f0-191123ae80ed",
      "avatarUrls": {
        "48x48": "https://secure.gravatar.com/avatar/2d0a884343444bc3f627e306f63d118?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FD-6.png",
        "24x24": "https://secure.gravatar.com/avatar/2d0a884343444bc3f627e306f63d118?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FD-6.png",
        "16x16": "https://secure.gravatar.com/avatar/2d0a884343444bc3f627e306f63d118?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FD-6.png",
        "32x32": "https://secure.gravatar.com/avatar/2d0a884343444bc3f627e306f63d118?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FD-6.png"
      },
      "displayName": "dkatrandzhiev",
      "active": true,
      "timeZone": "Europe/Athens",
      "accountType": "atlassian"
    },
    "created": "2023-11-03T23:33:42.230+0200",
    "size": 4585,
    "mimeType": "image/jpeg",
    "content": "https://myJira.atlassian.net/rest/api/2/attachment/content/10003",
    "thumbnail": "https://myJira.atlassian.net/rest/api/2/attachment/thumbnail/10003"
  }
}

 

 

1 answer

0 votes
Oday Rafeh
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.
Nov 08, 2023

Hi @dkatrandzhiev , 

When dealing with Jira Webhooks and the attachment creation event, a frequent hurdle is that the webhook payload does not provide specific details about the corresponding issue. The following steps can help you utilize the Jira REST API to determine the issue that an attachment is associated with:

Capture Attachment ID: From the webhook data, capture the attachment ID.

Use the REST API: Perform a GET request to the attachment/{id} endpoint, which provides the attachment metadata, including the issue ID.

Here's a general outline of the API call you would make:

GET /rest/api/2/attachment/{attachmentId}


This will return information about the attachment, including the issue or content URL, which should have the issue key within it.

However, based on your message, you're saying that even when using the API endpoint to get the attachment information, you're not receiving the issue ID. This seems unusual, as the API should return the issue ID in the response

Another approach, if feasible in your situation, is to modify your Jira workflow and add a custom webhook event that triggers upon attachment creation, which includes the issue key in the payload. This requires custom development and administrative access to the Jira instance.

 

Hope My answer Helped. 

Kind regards,

Oday Rafeh

dkatrandzhiev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Nov 08, 2023

Thank you very much for the advices!

Yes, I've tried it many times and the API request to 

/rest/api/2/attachment/{attachmentId}

returns the same data in JSON format as the actual webhook. 

I'll try with Jira workflow. 

Thanks!

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