Forums

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

Access API With Python - Fails to get response from server

reddwarfcrew
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, 2023

Hi, we have migrated from server->cloud.  I had python and vba happily interacting with the APIs but just can't get python to work with the cloud.

I can code it to work successfully with VBA, so I know my coding is good but for some reason python just won't work.

There's no response message, python just errors saying it has reached the max retries and didn't get a response.

I've had the network guys monitor and they say there is a 502 error (Bad Gateway I assume).

I've reverted to just doing a basic python script to query a single issue, but to no avail.

Has anyone got any ideas?

This is the python code structure per the JIRA API docs:

 


# This code sample uses the 'requests' library:

# http://docs.python-requests.org 

import requests from requests.auth
import HTTPBasicAuth
import json
url = "https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}"
auth = HTTPBasicAuth("email@example.com", "<api_token>")
headers = { "Accept": "application/json" }
response = requests.request( "GET", url, headers=headers, auth=auth ) print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

 


I've tired adding in "verify: False" but also no joy.

In VBA, I did have to make one additional change over the code that I had working with jira server and that was to add a header to set the user-agent which I have also tried in python but it didn't work.

Has anyone got any ideas please?

 

1 answer

0 votes
Matt Doar
Community Champion
December 16, 2023

Odd that. Any reason not to use the most common Python library to do all this?

https://jira.readthedocs.io/

reddwarfcrew
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 17, 2023

Yep, the on-prem code is actually using that but reverted to the JIRA API doc python example to rule out any issues.

Suggest an answer

Log in or Sign up to answer