Hi there, I'm working with the JIRA rest API and I know how to create a task as well as a single subtask but I need to create 7 sub-tasks at once.
def new_issue(): issue = requests.post(main_url + create_issue, data=json.dumps(task_data), auth=(user, pw), headers=headers) print(issue.json()) print(issue.json()['key']) sub_tasks = [ { "fields": { "project": { "key": "DEVO" }, "parent": { "key": issue.json()['key'] }, "summary": "Collectors", "assignee": { "schema": { "type": "user", "system": "assignee" }, "name": user, "key": "assignee", "operations": [ "set" ] }, "description": "STUF THAT I NEED TO DO", "issuetype": { "name": "Sub-task" }}},
The sub_tasks is a list of python dictionaries, I have tried to run a loop that would iterate through all of these and it does however, I get the following response:
{'errorMessages': ['Can not deserialize instance of com.atlassian.jira.rest.v2.issue.IssuesUpdateBean out of START_ARRAY token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@1874cde; line: 1, column: 1]']}
But I haven't found what that mean. If anyone knows that would be great!
I've also tried using the bulk issues endpoint but I get an error message that reads:
{'errorMessages': ['No issue data was provided by request'], 'errors': {}}
Thanks in advance!
Community moderators have prevented the ability to post new answers.
I'm not sure if this helps you but iteration should work. This is a simple bash-script doing that without a session but creates one each time.
generate_subtask() { cat <<EOF { "fields": { "project": { "key": "JIRA" }, "parent": { "key": "JIRA-1" }, "summary": "Sub-task of JIRA-1", "issuetype": { "id": "5" } } } EOF } for i in {1..5} do curl -u user:password -X POST -H "Content-Type: application/json" --data "$(generate_subtask)" https://jira.domain.com/rest/api/2/issue/ done
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.