Forums

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

Trouble with API while migrating to cloud version or Jira

Kevin Regan
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!
January 16, 2024

We're getting ready to migrate to Jira cloud and are currently testing out Atlassian Python API's Jira module but have encountered some issues. Some of the API calls are working but others are returning errors despite having the same inputs. Other calls are returning errors with no clear reasoning. I'm using commands from the docs found here.

 

For example, the following user commands both require the account_id as the argument. 

jira.user(account_id)
jira.get_user_groups(account_id)

When I run both commands with the same account_id variable jira.get_user_groups works and returns the correct data. However, jira.user returns and error saying:

requests.exceptions.HTTPError: The 'accountId' query parameter needs to be provided

I don't understand why the account_id would work for jira.get_user_groups but not for jira.user?

 

Similarly, I can get the watchers from an issue but I cannot add or delete them:

jira.issue_get_watchers(issue_key)
jira.issue_add_watcher(issue_key, user) 

I am able to get the watchers with the get_watchers command but the add and delete watchers commands always fails with this error:

Adding user me@university.edu to "KAN-1" watchers
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/jira.py", line 1346, in issue_add_watcher
    return self.post(
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 336, in post
    response = self.request(
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 260, in request
    self.raise_for_status(response)
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 497, in raise_for_status
    raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError

 

Another issue I'm facing is that I cannot create new issues but the traceback does not point out any clear issues. I have confirmed that 'KAN' exists as a project key already with jira.projects().

fields = {
    'project': {'key': 'KAN'},
    'summary': 'api_test_issue_01',
    'description': 'testing jira cloud api python package',
}
jira.issue_create(fields)

output:

Creating issue "api_test_issue_01"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/jira.py", line 1446, in issue_create
    return self.post(url, data={"fields": fields})
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 336, in post
    response = self.request(
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 260, in request
    self.raise_for_status(response)
  File "/autofs/projects-t2/grc/devel/jira_api_test/venv/lib/python3.8/site-packages/atlassian/rest_client.py", line 497, in raise_for_status
    raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError

 

1 answer

1 accepted

0 votes
Answer accepted
Sunny Ape
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 Leaders.
January 16, 2024

I'd be inclined to think that the Atlassian Python API library is at fault, as this is not the first time such problems with the library have been described.

That library was created for Jira Server and calls only v2 endpoints. Given that not all the Jira Cloud v2 endpoints are a like-for-like match with their Jira Server cousins, those sorts of problems can be expected. This is one of the downsides of using a public library to 'shortcut' your API requests instead of making 'raw' requests using a Python native function.

Time to start de-coupling your code from its dependency on that library and switch to the Requests library. Also, start getting used to the v3 endpoints, as they will eventually replace all the old v2 ones.

Kevin Regan
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!
January 17, 2024

Thanks, this seems to be the issue. I was able to get the data I need with requests. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events