Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

401-unauthorized python rest api and curl

Angel
June 28, 2019

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

################################################

 

1 answer

1 vote
Dave O'Brien
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 15, 2015

Even better would be improving the create-link dialog to let you pick a page, then choose to show either:

  • all the headings on that page to link to, or
  • all the anchors on that page to link to

...then the system would build the URL internally so we don't have to mess with it.  smile

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events