How to post image in subtask

James Lewis April 16, 2018

Hi All,

Working on a project which has a Sub-task. I have a Jira API feed which is working well, Id now like to add to this API and add an image to the sub-task field "attachments".

 

Does anyone have a  Json (application/json) example of how this can be achieved, please?

 

Oh I'm currently using "Postman" to test the API so if you have an example I can put in that, then great!

 

Thanks

James

 

1 answer

0 votes
Mauricio Karas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 20, 2018

Hello, James.

The API call should be as the following:

POST {jira_url}/rest/api/2/issue/{issueIdOrKey}/attachments

This works for issues and subtasks.

To actually send the image using postman, you need to click in body, then select form-data, in the key field you need to type "file" and then you can change the value from text to file, an option to "choose files" should appear.

body2.png

 

Also, in order to protect against XSRF attacks, because this method accepts multipart/form-data, it has XSRF protection on it. This means you must submit a header of X-Atlassian-Token: no-check with the request, otherwise, it will be blocked.

header.png

 

Kind regards,
Maurício Karas

Suggest an answer

Log in or Sign up to answer