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" } }
Did you ever find the solution to this? I am having the exact same issue.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The information provided by @Oday Rafeh is not correct.
The Get Attachment Metadata API endpoint does not return any metadata that contains the Issue ID.
It also does not return a content URL that contains "the issue key within it".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.