Forums

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

Upload an image to Jira automation with webhook

Mo December 23, 2024

We would like to integrate the jira webhook to our iOS app to bring the bug report functionality to our user.

The webhook is configured and working fine as whenever the user do a report (making a POST call from the app with the payload) it creates a JIRA ticket for that issue. however to make it even better, we want to allow users to attach images to the bug report. So the image can also be attached to the ticket.
How to do that?

1 answer

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
December 27, 2024

Hi @Mo 

You can use Jira's upload attachment REST Api for that.

POST /rest/api/3/issue/{issueIdOrKey}/attachments

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post 

Mo December 31, 2024

Thanks @Tuncay Senturk _Snapbytes_ ,
I already looked at this REST Api, however in my case, when calling the webhook, there is not issue created yet (that's going to be handled by the webhook trigger)
Therefore I don't have the issue id/number to use this api to attach to it.

Tuncay Senturk _Snapbytes_
Community Champion
December 31, 2024

Ah, I see!

As far as I know, the Jira REST API does not allow you to attach a file at the same time as creating an issue in a single request. You have to do this in two sequential API calls.

Like Mo likes this
Mo January 8, 2025

Thanks for the tip Tuncay!
What I am doing now is to make a first call to the webhook, to trigger the issue creation, then making a second call to search/fetch the id of the created issue, then making a third call to upload the attachment for that issue.

This is working for now, but for the sake of managing the API token, I guess we need to implement something in the backend to manage the token handling.

Tuncay Senturk _Snapbytes_
Community Champion
January 9, 2025

Hi @Mo 

The create REST method (POST /rest/api/3/issue) already returns the issue ID / key. I do not understand why there is a need to make the second call to retrieve them.

Mo January 9, 2025

the idea is to create the issue through a trigger by the webhook, and not by making a POST call. This way we trigger the automation in the Service Desk Management. 
Does calling the `/rest/api/3/issue` can be configured to create the issue under the JSD?

Suggest an answer

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

Atlassian Community Events