You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I’m receiving a 401 Unauthorized error when trying to post attachments to the Jira Cloud.
my code in python:
##################################################
import glob
import requests
import json
import time
def upPagare(pagare):
tmp = pagare.split('.')
noAct = tmp[0]
url = 'https://pochteca.atlassian.net/rest/api/2/issue/'+noAct+'/attachments'
headers = {"X-Atlassian-Token": "nocheck"}
# please uncomment to attach external file
files = {'file': open(pagare, 'rb')}
r = requests.post(url, auth=('aferreirao@pochteca.com.mx', 'lalala'), files=files, headers=headers)
print(r.status_code)
print(r.text)
pagares = [f for f in glob.glob("*.pdf")]
for x in range(len(pagares)):
print("updating :" + pagares[x])
upPagare(pagares[x])
print("success:" +pagares[x])
time.sleep(10)
#################################################
I almost try with Curl:
##############################################
curl -D- -u aferreirao@pochteca.com.mx:lalala -X POST -H "X-Atlassian-Token: nocheck" -F "file=@C:\Users\aferreirao\Desktop\CAP-16041.pdf" https://pochteca.atlassian.net/rest/api/2/issue/CAP-16041/attachments
################################################
Hi @Angel
I think the issue might be that you're using a password instead of a token - see this Atlassian article for further info (there's also a link within the article with more info on using a token)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm able to login to Jira and get the data, the problem comes with the POST method. I'm getting a 401 error, could you please help me with that. Below is my code!
data = {
"key": "RESV1",
"name": "Resv1",
"url": "rest/api/2/project",
"projectTypeKey": "software",
"projectTemplateKey": "TSWSIDSOT",
"lead": "*************",
"assigneeType": "PROJECT_LEAD",
"permissionScheme": 10900,
"notificationScheme": 10709,
"categoryId": 11000
}
data = json.dumps(data)
data = json.loads(data)
headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
r = requests.post(url, json=data, auth=("USERNAME", "PASSWORD"), verify=False)
print(r.json)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.