Hello, I am having an issue creating attachments for an existing issue using the REST API.
1. When I do a GET request to view my target issue, I am able to view the issue.
curl --request GET --user <email:api-key> --header 'Accept:application/json' <organization domain>/rest/api/3/issue/{id}?fields=summary
{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"{id}","self":"<organization domain>/rest/api/3/issue/{id}","key":"{key}","fields":{"summary":"Target for attachments"}}
2. When I do a GET request to view my permission to create attachments, I see that I have permission to create attachments.
curl --request GET --url <organization domain>/rest/api/3/mypermissions?permissions=CREATE_ATTACHMENTS --user <email:api-key> --header 'Accept:application/json'
{"permissions":{"CREATE_ATTACHMENTS":{"id":"19","key":"CREATE_ATTACHMENTS","name":"Create Attachments","type":"PROJECT","description":"Users with this permission may create attachments.","havePermission":true}}}
Based on these two requests, I expected that I would be able to create an attachment for the relevant issue.
However: When I create a POST request to create an attachment, the response tells me that I can't access the issue.
curl --location --request POST <organization domain>/rest/api/3/issue/{issue}/attachments --user <email:api-key> --header X-Atlassian-Token:nocheck --form file=@"<path>\Test.txt"
{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}
Does anyone know what's happening here? I don't understand how to approach this issue. Thank you in advance for your help.
Hi @Glenn Bousfield ,
You seem to be on the right track. The API syntax you’re using is mostly correct, but there are a few things to consider:
Syntax Check
Double-check the syntax, especially the header and file path. Consider adding quotes around the header like this:
--header 'X-Atlassian-Token: no-check'
Also for the simplicity consider running the script from the same directory where the attachment is located. This will allow to ensure that there is no issues with regard to path of the file.
file=@"Test.txt"
Atlassian documentation offers code snippets in various languages. Consider giving it a shot with some different approach on language You are familiar with, to isolate terminal/escaping issues
Cheers, mate. Happens to the best of us.
Hi Pears,
Thanks for the helpful response.
I tried changing the syntax a few different ways and then at some point it worked. I am not sure what specifically needed to be fixed but now it works.
Cheers,
Glenn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's awesome. Thanks for the update, Glenn!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.