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

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

 

2 answers

1 accepted

0 votes
Answer accepted
Guilherme V.
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 31, 2015

Hi there,

You could take a look on this documentation:

Cheers,

 

0 votes
Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
August 31, 2015

Is there a reason not to use Postgres? As far as I understand, your Express edition will not be covered by a support contract, so Postgres may actually be better quality, open-source and unlimited.

It's also cheaper for your Norvegian provider to host a (Postgres) database because it's on Unix (Linux), rather than a Windows-based database which requires much more powerful hardware and a license of Windows Server. At least, on Unix, deployments can be scripted.

Roger Oshaug
September 2, 2015

Would an installation in Microsoft Azure be covered by a support contract, as long as the server version and database version are in compliance with your requirements?

Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 2, 2015

Hi Roger, this is an ecosystem forum and I don't belong to Atlassian. When mentionning the support coverage, I was talking about Microsoft not supporting the Express edition, since it's a free edition.

Roger Oshaug
September 2, 2015

Ok, thank you for the advice.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events