When utilizing Python to access the REST API for Jira Cloud I get inconsistent returned results. For instance, using the recommended Python code at https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/#api-rest-api-3-field-get, I receive a proper returned response using the url: https://{company}.atlassian.net/rest/api/2/field.
However, when I try to get create metadata using guidance at https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-createmeta-projectidorkey-issuetypes-issuetypeid-get:
{
“errorMessages”: [
“You cannot create issues in this project.”,
“You are not authorized to perform this operation. Please log in.”
],
“errors”: {}
}
but on the same machine I can
curl -D- -u {user:token} -X GET -H “Content-Type: application/json” https://{company}.atlassian.net/rest/api/2/issue/createmeta/{project}/issuetypes
and receive a correct response. So anytime I try to get createmeta data from Python using requests the system will not adjudicate but it seems to be happy at all other times.
I’ve also tried recreating the reported information from successful curl runs
in Python with:
headers = {
“Accept”: “application/json”,
“Content-Type”: “application/json”,
‘transfer-encoding’: ‘chunked’,
‘connection’: ‘keep-alive’,
‘content-encoding’: ‘UTF-8’,
}
and using a session instead of a straight request like:
s = requests.Session()
s.auth=auth
s.headers=headers
s.proxies = {“http”: http_proxy,“https”: https_proxy}
s.verify = verifyresponse = s.get(url1)
NOTE:
- Functionality is the same with both version 2 and 3 url constructs.
- I have administrator access for the project in question
- I’m using Python3.8.14 with Requests2.32.3
- I’ve tried both General and Specific Jira access tokens
- I’m on a Redhat 8.8 machine
- Issuing the createmeta url in a browser on a Windows machine works.
- Opening a session, issuing a get fields request followed by a createmeta request before closing the session also fails.
