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

JSON format for Creating JIRA Issue with Attachment using REST

Eswaran R August 26, 2015

Hi All,

 

I want to Integrate JIRA with third party application. I can create JIRA issue successfully without any attachment by using following JSON.

{ "fields": { "project": { "id": "10000" }, "summary": "No REST for the Wicked.", "description": "Creating of an issue using ids for projects and issue types using the REST API", "issuetype": { "id": "3" } } }

Third party application simply post the JSON to JIRA and its creates the Issue. I want to know JSON format for create issue with attachment.

Note : Am not using CURL. Only posting JSON data from third party application which supports REST API to JIRA.

 

Thanks

Eswaran

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Danut M _StonikByte_
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.
February 15, 2019

The attachments API method does not support JSON. It expects a multipart post.

See https://docs.atlassian.com/software/jira/docs/api/REST/7.13.0/#api/2/issue/{issueIdOrKey}/attachments-addAttachment

I managed to use it with PostMan.

Header must contain:

Content-Type: multipart/form-data

X-Atlassian-Token: no-check 

PM_Headers.jpg

Body must be of type "form-data" and must contain a key named "file" with value a specified file (I had to use the file picker, see the picture).

PM_Body.jpg

0 votes
GabrielleJ
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.
August 27, 2015

Similar question has been posted in https://answers.atlassian.com/questions/249347. Since REST does not care what do you use to communicate with it as long as it is properly formatted, it will always work.

Eswaran R August 27, 2015

Hi Gabrielle, Thanks for your reply. But the third party application will accept only JSON input to perform JIRA operation. I can create Issue in JIRA by passing above JSON in that third party application. likewise, Is there any JSON format to attach a file in JIRA?

GabrielleJ
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.
August 28, 2015

Yes, take a look at this documentation. It's as simple as the command below. No JSON body needed curl -D- -u admin:admin -X POST -H "X-Atlassian-Token: nocheck" -F "file=@myfile.txt" http://myhost/rest/api/2/issue/TEST-123/attachments

Eswaran R September 1, 2015

Hi Gabrielle,

        For testing purpose, am using Chrome Extension  "Insomnia" which is used to call the REST service. 

 

 

REST.jpg

Here, Body and Params both are empty. Why am getting 415-Unsupported Media Type Error ? Where should I include the file=@filename.txt option here?

Yuvraj Kale July 5, 2017

Hi Eswaran,

Did you solved this issue using JSON format? I am facing similar issue in my project. Please help me here to upload attachement with JSON format. Currently i am developing this with node.js 

Thanks is advance.

Eric Sacramento April 27, 2018

I need the same solution. I am using Oracle Apex. It would be easier using just the JSON format instead of curl command.

Thank you

TAGS
AUG Leaders

Atlassian Community Events