1

I am using python to automate JIRA process, while doing I am unable to update Assignee and Comment fields.

While updating Assignee field, not getting any error, but the value is not updated properly, I am trying to assign from one user to other user, but it is getting updated as Unassigned

For comment field, getting an error.

Below is my code:

from atlassian import Jira
jira_instance = Jira(
    url = "https://****.atlassian.net/",
    username = "****@gmail.com",
    password = "*******",
)

data = jira_instance.jql("project = PROJECTNAME AND status = 'IN PROGRESS' ORDER BY created ASC", fields=['description','assignee','reporter','comment'])

for i in range(len(data["issues"])):
    test_data = data["issues"][i]
    jira_instance.issue_update(test_data['key'], fields={'assignee':{'emailAddress': '####@gmail.com' }})
    jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})

Also tried using displayName instead of using emailAddress, but still same thing happens.

For comment field, got the below error:

Traceback (most recent call last):
  File "c:/Users/path/jiratest.py", line 13, in <module>
    jira_instance.issue_update(test_data['key'], fields={'comment':{'comments': [{'body':'This is the comment'}]}})
  File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 891, in issue_update
    return self.put(url, data={"fields": fields})
  File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 341, in put
    absolute=absolute,
  File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\rest_client.py", line 236, in request
    self.raise_for_status(response)
  File "C:\Users\path\AppData\Local\Programs\Python\Python37\lib\site-packages\atlassian\jira.py", line 3705, in raise_for_status
    raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError

Please anyone help me out on this

2 Answers 2

1

You haven't said if you're using Jira Cloud or Server.

For Jira Cloud, you must set the assignee for an issue using that person's account ID, not their username or email address, so the request would look something like:

jira_instance.issue.update(assignee={'accountId': '5b10ac8d82e05b22cc7d4ef5'})
Sign up to request clarification or add additional context in comments.

Comments

1

For adding a comment field, try something like this:

jira_instance.issue_add_comment(test_data['key'], 'This is the comment')

For updating the assignee, try this:

jira_instance.update_issue_field(test_data['key'], fields={"assignee": "####"})

2 Comments

adding a comment field worked as you suggested, but updating the assignee still not working. Its becomes Unassigned, not the other user. Please help me on updating assignee field. Thanks for your help
I'm also getting same error while trying to use issue_update or update_issue_field API. requests.exceptions.HTTPError: Internal server error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.