Python search_issues API not working for some projects in list

Rafay Sheikh
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!
March 31, 2024

Hello,

I am writing my code in python. Trying to fetch issues and get changelog info. I have been trying to call the search_issues() api for a list of projects. The authentication and getting response results seems to be work for majority of the projects in the list. There is a handful of projects for which I am getting errors. Its seems for those projects I am getting no data or response but the same code works for others.

ERROR:jira:Expecting value: line 1 column 1 (char 0)
....
Traceback (most recent call last):
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/home/rafaysheikh/.pyenv/versions/3.8.12/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/home/rafaysheikh/.pyenv/versions/3.8.12/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/rafaysheikh/.pyenv/versions/3.8.12/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/rafaysheikh/Downloads/run_jira_section.py", line 48, in <module>
df = jira.run_section(
File "/home/rafaysheikh/dna_data_ops/pipelines/integration_pipelines/connectors/connectors/base/base_connector.py", line 42, in run_section
return func(*args, **kwargs)
File "/home/rafaysheikh/dna_data_ops/pipelines/integration_pipelines/connectors/connectors/base/base_section.py", line 40, in __call__
return self.func(*args, **kwargs)
File "/home/rafaysheikh/dna_data_ops/pipelines/integration_pipelines/connectors/connectors/jira/sections/change_log.py", line 206, in func
updated_issues = client.search_issues(
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/jira/client.py", line 3557, in search_issues
issues = self._fetch_pages(
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/jira/client.py", line 890, in _fetch_pages
resource = self._get_json(
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/jira/client.py", line 4364, in _get_json
raise e
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/jira/client.py", line 4361, in _get_json
r_json = json_loads(r)
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/jira/utils/__init__.py", line 77, in json_loads
return resp.json()
File "/home/rafaysheikh/.local/share/virtualenvs/connectors-WMohEYKM/lib/python3.8/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ERROR:root:Expecting value: line 1 column 1 (char 0)
ERROR:root:Expecting value: line 1 column 1 (char 0)
INFO:root:Expecting value: line 1 column 1 (char 0)


There is a external for loop going over each projects and calling this API. The 3 projects its crashing on should have lots of data (Issues)so in my api call I have the maxResults set to False. Out of 30+ projects it crashes on a few with the errors above. Not sure if this is json response error or line 1 column 1 suggests that we are getting no data because of some other error (auth or jql)?

 

Look back day is 3 days from current date and next day is the day after current date.

 

for project in project_list:

updated_issues
= client.search_issues(

jql_str=f'project="{project}" and updated >="{look_back_date}" and updated <"{next_date}"',

fields=["changelog"],

expand="changelog",

maxResults=False,

validate_query="warn",

json_result=False,

)

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 3, 2024

Hi, make sure that the project variable is correct, try to print the jql and use it in the UI, Jira will tell you what is wrong.

Suggest an answer

Log in or Sign up to answer