I can create a subtask fine following this documentation, JIRA REST API Example Create Issue 7897248 (atlassian.com). My current implementation sets a custom field to the due date value which is calculated previously in my script. However, when trying to set the native Due Date field and the priority field like I have in previous functions in my script, I get a 400 error as output.
If anyone can provide any insight on if the rest api can support doing this on creating of the subtask, if my payload format is wrong, or if I would have to implement a different solution to update the subtasks after they are created it would be greatly appreciated, thanks!
Here is my function as it is now.
function JiraSubtask ($issue, $next_review_date) {
$update_issue_url = "$jiraURL/rest/api/2/issue/"
$createSubtaskBody = @{
fields = @{
project = @{
key = $projectKey
}
parent = @{
key = $issue.key
}
summary = "This vendor is 21 days from their next review date $duedate"
description = "Please review this vendor's risk score and update the appropriate custom fields before $duedate"
issuetype = @{
name = "Sub-task"
}
$subtask_duedate_id = $duedate
}
} | ConvertTo-Json
Write-Output $create_subtask_body
Invoke-RestMethod -Method Post -Uri $update_issue_url -Headers $headers -Body $createSubtaskBody -ContentType "application/json" -Verbose
}
Hello @djohnson
Welcome to the Atlassian community.
Have you reviewed the possible causes of the 400 response?
400Bad Request
Returned if the request:
Is the actual value that you are trying to assign to the Due Date field in a format that is acceptable for that field? Is the Due Date field available on the Subtask issue type?
The due date field is present on the sub task. In my script I am able to set the due date field of the parent issue fine, so the format of the data and the field name being called to should be fine. It is not a permissions error; I have the right level of access and have not had trouble altering any of the custom fields or native fields for the parent issues earlier in my script. It generates the sub task in the same project and is generating the sub task fine. My theory is that the api does not support setting the due date native field or the priority native field when the issue is created. I have also been able to successfully set the priority native field with the parent issues as well, I am only running into issues when trying to do it with the subtasks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you able to set those fields for subtasks through the UI? Are they included on the Create/Edit screens for the subtask issue type?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can set those from the UI but only from the Edit screens not the create screen. However, I can't set custom fields from the create screen but as it is implemented now, I can still populate custom fields when the sub task is created.
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.