When I try to add an attachemnt with the API (code below), I get the error:
"You do not have permission to create attachments for this issue."
url = self.base_http_url + 'rest/api/2/issue/' + issue_id + '/attachments'
headers = {'X-Atlassian-Token': 'no-check'}
r = requests.post(url, auth=self.auth, headers=headers, files=files)
Why am I getting this error? The user is admin and can successfully do everything else.
I apparently forgot to enable attachments on my dev machine, but now I'm getting a 200 status code, but response is empty and the file is not attached.
So, apparently the file in the request has to have the "name" "file":
url = self.base_http_url + 'rest/api/2/issue/' + issue_id + '/attachments'
headers = {'X-Atlassian-Token': 'no-check'}
files = {}
for file in attachments:
files['file1'] = open(file, 'rb')
r = requests.post(url, auth=self.auth, headers=headers, files=files)
But I can't upload multiple files like this...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've given up and will send one file at a time.
def add_attachment(self, issue_id, attachments):
# add attachments to Jira issue
url = self.base_http_url + 'rest/api/2/issue/' + issue_id + '/attachments'
headers = {'X-Atlassian-Token': 'no-check'}
files = {}
r = []
if len(attachments) < 1:
r.append('ERROR: No files attached')
for file in attachments:
files['file'] = open(file, 'rb')
r.append(requests.post(url, auth=self.auth, headers=headers, files=files))
files['file'].close()
return r
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.