Forums

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

Json attachment Jira

Wagner Alcantara
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!
January 26, 2022

good afternoon I'm creating a file to open an issue in jira service management but I needed to attach files, which parameter can I include in the json?

2 answers

3 votes
Marini Marini
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.
January 26, 2022

Hi Wagner,

Thanks for reaching out to the Atlassian Community!

From the description, I think you are trying to write a script that will create a JSM issue with the attachment.

If you do, we can not pass a path to the file in the JSON request parameter. Instead, your script will need to call two JSM REST APIs (assuming you are using JSM Cloud)

1. Call the REST API to create an issue

For example:

curl --request POST --url https://your-domain.atlassian.net/rest/api/3/issue -u 'email@example.com:<api_token>' --data '{"fields": {"summary": "Test the automation","issuetype": {"id": "<issuetype-id>"},"project": {"key": "IP"},"description": {"type": "doc","version": 1,"content": [{"type": "paragraph","content": [{"text": "This is the description.","type": "text"}]}]}}}' --header 'Accept: application/json' 

When the issue is created successfully, you will receive a response similar to below:

{
  "id": "10000",
  "key": "IP-16",
  "self": "https://your-domain.atlassian.net/rest/api/3/issue/10000",
}

 Grab that Issue id in your script.

2. Then, call another REST API to add an attachment

For example:

curl --location --request POST 'https://your-domain.atlassian.net/rest/api/3/issue/IP-26/attachments' -u 'email@example.com:<api_token>' -H 'X-Atlassian-Token: no-check' --form 'file=@"a.png"'

I hope it helps.

Cheer!

0 votes
Marini Marini
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.
January 26, 2022 edited

duplicate answer (removed)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events