The attachment section of my issue has 2 categories, lets say 'Standard' and 'Data'. This URL: 'http://myhost/rest/api/2/issue/TEST-123/attachments' attaches my files in 'Standard' category. What change needs to be made in the URL or the body in order for files to be attached in 'Data' category
First API Call worked, I got the Category ID. For the second one I got API Call Error (500) . What could be the reason for that?
Endpoint :- 'POST/rest/attach-cat/1.0/attachments'
Parameter :- issueKey=Test-123
tempAttachments=[{\"name\":\"LocalPath\reports.docx\", \"categoryId\":0}]
I tried to put that under Body too, still got 500 Error Code
Body :-"issueKey=Test-123&tempAttachments=[{\"name\":\"LocalPath\reports.docx\", \"categoryId\":0}]"
What was the error?
issueKey=Test-123 should be issueKey=TEST-123
and value of tempAttachments should be JSON string (JSON.stringify
(data))
Have you checked headers that you are passing?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It not clearly visible but I don't see any headers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not passing anything in the header. What needs to be passed?
issueKey=Test-123
tempAttachments=[{\"name\":\"LocalPath\reports.docx\", \"categoryId\":0}]
I tried passing the above as header too, but it still did not work.
I really need a way to work this out for the client.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Above information need to passed as data not headers. I wanted to state that 'Test-123' should be 'TEST-123'
You can use Atlassian Rest API Browser to test API right from Jira Admin UI. Once you get hold of request there then try it from outside.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you say passing as Data - does that mean Parameter, Body or Resource (marked in yellow)
Passing it just in the resource gave me 412 status code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to pass data as body.
Have you tried Altassian Rest API Browser, it will easier for you to try there before using any other tool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I try passing data as body, I get 500 error code.
For Altassian Rest API Browser, do I need any Atlassian application? Since, I don't have one, what is best approach?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By default Jira Attachment doesn't have any category, are you using any plugin like "Smart Attachment"?
If you are using plugin, you need to refer plugin API how to categorize attachment after adding them to an issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe so yes, the client is using Smart Attachment. The process which I am working for my client involves adding attachments to the Data Category of the issue using Jira REST API. Is there a way I can find the ID of the Data Category and use that ID to add attachment ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Categories of Attachment are created by `Smart Attachment` plugin so you will not be able to use it via Jira Standard Rest APIs.
But you can use Rest APIs provided by Smart Attachment plugin to assign categories to attachment.
Please look here this will solve your problem - https://docs.stiltsoft.com/display/public/CATAT/Managing+Attachments+with+REST+API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I am very new to Jira Rest APIs.
Should I try one of these methods?
I can upload the attachments to Standard Category, get all the attachment Id's and then move them to Data category
2. Did not quite understand this method
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2 seems to be a better way. Here is how you can do this,
Let say you want to attach file `reports.docx` to issue `SP-1`
Using API provided by Smart Attachment plugin, you will first assign desired category to filename associated with issue.
curl -D- -u admin:admin --request POST
"https://<jira_home>/rest/attach-cat/1.0/attachments"
--data
"issueKey=SP-1&tempAttachments=[{\"name\":\"reports.docx\", \"categoryId\":0}]"
Now you have assigned category with ID `0` to file `reports.docx` before it is uploaded to Jira.
Now you need to call standard Jira API to upload file
curl -D- -u admin:admin -X POST -F "file=@reports.docx" http://<jira_home>/rest/api/2/issue/SP-1/attachments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, you are suggesting to make 3 API calls? I am using SOAP UI to achieve this
1. API call to get Category Id
Endpoint :- 'GET/rest/attach-cat/1.0/attachments?issueKey=TEST-123'
2. After getting the Category ID (0) from the JSON string, make an API call to assign it to the attachment
Endpoint :- 'POST/rest/attach-cat/1.0/attachments'
Body or Parameter ? :- "issueKey=Test-123&tempAttachments=[{\"name\":\"reports.docx\", \"categoryId\":0}]"
3. API call to add attachment
Endpoint :- POST/rest/api/2/issue/Test-123/attachments
Attachment :- file:"reports.docx"
Header :- X-Atlassian-Token:"nocheck"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i have the same issue in 2024 any help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
so i found the solution that works , in my case i did 3 api calls
1. API call to get Category Id
Endpoint :- 'GET/rest/attach-cat/1.0/attachments?issueKey=TEST-123'
2. API call to add attachment
Endpoint :- POST/rest/api/2/issue/Test-123/attachments
Attachment :- file:"reports.docx"
Header :- X-Atlassian-Token:"nocheck"
and i get from the response the attachemet id which i send in my 3rd api call , for exemple 3
3. API call to move the attachement
endpoint POST rest/attach-cat/1.0/attachments/move
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Show up and give back by attending an Atlassian Community Event: we’ll donate $10 for every event attendee in March!
Join an Atlassian Community Event!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.