Hi,
According to this: https://jira.atlassian.com/browse/JSWCLOUD-22718
its now possible to update the Parent of a subtask through the API. Does anyone know how to do this through Python? I've tried the following but no dice:
sub_task_issue.update(parent=test_issue.key)
sub_task_issue.update(fields = {'parent': test_issue})
sub_task_issue.update(parent = test_issue)
I'm getting errors like:
response text = {"errorMessages":[],"errors":{"parent":"data was not an object"}}
or
TypeError: Object of type Issue is not JSON serializable
Thanks in advance!
This turned out to be the correct syntax:
sub_task_issue.update(fields = {'parent': {'key': str(test_issue.key)}})
I can't even begin to tell you how much this little line helped. Every other key:value pair in our code uses "value" or "name" for the key. But for some reason (probably because parent is newer), the key for parent is LITERALLY "key".
Thanks again lol.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Whatever Python library you are using, it is not sending the right data to Jira.
Either you're not feeding the function valid data, or the library has a bug. Whichever it is, the JSON that the REST call is sending is malformed and Jira can't read it.
What is providing the function sub_task_issue.update ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://pypi.org/project/jira/
I'm using the above, i think i might just have the 'update' syntax wrong for updating Parent.
I've used it before to update fields in Jira like so:
sub_task_issue.update(fields = {'customfield_12389': {'value': "XYZ"}})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def update(
self,
fields: Optional[Dict[str, Any]] = None,
async_: Optional[bool] = None,
jira: "JIRA" = None,
notify: bool = True,
**kwargs: Any,
):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Figured it out eventually :
sub_task_issue.update(fields = {'parent': {'key': str(test_issue.key)}})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I am using JIRA library in python for the automation.
And, I am using below code to create child issue using parent issue's key, but I am getting the error.
parent_issue_data = {
"project": {"key": project_name},
"summary": main_task,
"issuetype": {"name": "Task"},
}
parent_issue = jira.create_issue(fields=parent_issue_data)
child_issue_data = {
"project": {"key": project_name},
"summary": main_task,
"issuetype": {"name": "Task"},
"parent": {'key': 'ANTAR-28'}
}
child_issue = jira.create_issue(fields=child_issue_data)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AttributeError Traceback (most recent call last)
File c:\raaj\python\JiraAutomation\.reqenv\lib\site-packages\atlassian\rest_client.py:436, in AtlassianRestAPI.raise_for_status(self, response)
434 else:
435 error_msg = "\n".join(
--> 436 j.get("errorMessages", list()) + [k.get("message", "") for k in j.get("errors", dict())]
437 )
438 except Exception as e:
File c:\raaj\python\JiraAutomation\.reqenv\lib\site-packages\atlassian\rest_client.py:436, in <listcomp>(.0)
434 else:
435 error_msg = "\n".join(
--> 436 j.get("errorMessages", list()) + [k.get("message", "") for k in j.get("errors", dict())]
437 )
438 except Exception as e:
AttributeError: 'str' object has no attribute 'get'
During handling of the above exception, another exception occurred:
HTTPError Traceback (most recent call last)
Cell In[48], line 59
---> 59 child_issue = jira.create_issue(
...
1018 )
1020 if http_error_msg:
-> 1021 raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request for url: https://raajchauhan.atlassian.net/rest/api/2/issue?updateHistory=false
Thanks for your responce.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My issue is resolved.
They changed the issue type parameter syntax.
My previous code:
"issuetype": {"name": "Sub-task"},
And, Here is my current working code:
"issuetype": {"name": "Subtask"},
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.