Я пытаюсь работать с JIRA API, используя python. Я использовал пример с этой страницы https://www.opentechguides.com/how-to/article/python/185/jira-python-rest.html
, и в целом он работал до того, как я изменил фильтр с
project = PKY на project = INN и type = Epic
Я получаю следующую ошибку
Traceback (most recent call last): File "D:\work\py\jirafirst\venv\lib\site-packages\urllib3\response.py", line 388, in _decode
data = self._decoder.decompress(data) File "D:\work\py\jirafirst\venv\lib\site-packages\urllib3\response.py", line 85, in decompress
ret += self._obj.decompress(data) zlib.error: Error -3 while decompressing data: incorrect header check
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "D:\work\py\jirafirst\venv\lib\site-packages\requests\models.py", line 750, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True): File "D:\work\py\jirafirst\venv\lib\site-packages\urllib3\response.py", line 564, in stream
data = self.read(amt=amt, decode_content=decode_content) File "D:\work\py\jirafirst\venv\lib\site-packages\urllib3\response.py", line 536, in read
data = self._decode(data, decode_content, flush_decoder) File "D:\work\py\jirafirst\venv\lib\site-packages\urllib3\response.py", line 391, in _decode
raise DecodeError( urllib3.exceptions.DecodeError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "D:/work/py/jirafirst/1.py", line 21, in <module>
response = requests.request( File "D:\work\py\jirafirst\venv\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs) File "D:\work\py\jirafirst\venv\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs) File "D:\work\py\jirafirst\venv\lib\site-packages\requests\sessions.py", line 686, in send
r.content File "D:\work\py\jirafirst\venv\lib\site-packages\requests\models.py", line 828, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b'' File "D:\work\py\jirafirst\venv\lib\site-packages\requests\models.py", line 755, in generate
raise ContentDecodingError(e) requests.exceptions.ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect header check'))
sample
import requests
import json
import base64
# Base encode email and api token
cred = "Basic " + base64.b64encode(b'myemail@otg.com:pQcIDzMucUS76VBUmwzp2012').decode("utf-8")
# Set header parameters
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization" : cred
}
# Enter your project key here
projectKey = "PKY"
# Update your site url
url = "https://mysite.atlassian.net/rest/api/2/search?jql=project=" + projectKey
# Send request and get response
response = requests.request(
"GET",
url,
headers=headers
)
# Decode Json string to Python
json_data = json.loads(response.text)
# Display issues
for item in json_data["issues"]:
print(item["id"] + "\t" + item["key"] + "\t" +
item["fields"]["issuetype"]["name"] + "\t" +
item["fields"]["created"]+ "\t" +
item["fields"]["creator"]["displayName"] + "\t" +
item["fields"]["status"]["name"] + "\t" +
item["fields"]["summary"] + "\t"
)