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
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.
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 ?
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
Sorry, I am very new to Jira Rest APIs.
Should I try one of these methods?
1. https://docs.stiltsoft.com/display/public/CATAT/Managing+Attachments+via+REST+API#ManagingAttachmentsviaRESTAPI-Movingattachmentsfromonecategorytoanother
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
https://docs.stiltsoft.com/display/public/CATAT/Managing+Attachments+via+REST+API#ManagingAttachmentsviaRESTAPI-Puttingattachmentstocategoriesbeforeupload
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 (<span>JSON</span><span>.</span><span>stringify</span>(data))
<span>JSON</span><span>.</span><span>stringify</span>
Have you checked headers that you are passing?
I don't think I am passing anything in the header.
Please see the attached screenshot and let me know what needs to be changed/added
It not clearly visible but I don't see any headers.
It looks like you're new here. Sign in or register to get started.