Unable to create subtasks using REST API

chaitali agarwal December 28, 2017

I am able to create JIRA subtasks manually but when I use Postman POST request for doing the same I am getting below error.

"The default assignee does NOT have ASSIGNABLE permission OR Unassigned issues are turned off"

I am following the same steps explained at https://developer.atlassian.com/jiradev/jira-apis/about-the-jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue?_ga=2.266412365.272927713.1514442347-2114113685.1505727766#JIRARESTAPIExample-CreateIssue-Exampleofcreatinganissueusingprojectkeysandfieldnames

Using below data for my POST request:

{
"fields":
{
"project":
{
"key": "XX"
},
"parent":
{
"key": "XXX-3604"
},
"summary": "Some text",
"description": "some text",
"issuetype":
{
"id": "10",
"assignee":
{
"name": "username"
}
}
}
}

Can anyone help me pointing out to the issue as creating subtask is manually possible. Is there any other setting required before creating sub-task through REST API's.

 

Please help, its urgent!

 

4 answers

0 votes
Dragan Vucanovic February 22, 2018

i also have an issue:

 

{
"fields":
{
"project":
{
"key": "TEST"
},
"parent":
{
"key": "TEST-456"
},
"summary": "Sub-task of mycompany-456",
"description": "Don't forget to do this too.",
"issuetype":
{
"id": "5"
}
}
}

 

put json file into variable:value=`cat my.json`

 

curl -D- -u user:pass -X POST --data $value -H "Content-Type:application/json" https://jira.company.com/rest/api/2/issue/

 

curl: (6) Could not resolve host: "fields"; Name or service not known
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: "project"; Name or service not known
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: "key"; Name or service not known
curl: (6) Could not resolve host: "TECH"; Name or service not known
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (6) Could not resolve host: "parent"; Name or service not known
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: "key"; Name or service not known
curl: (6) Could not resolve host: "TECH-456"; Name or service not known
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (6) Could not resolve host: "summary"; Name or service not known
curl: (6) Could not resolve host: "Sub-task; Name or service not known
curl: (6) Could not resolve host: of; Name or service not known
curl: (6) Could not resolve host: TEST-456",; Name or service not known
curl: (6) Could not resolve host: "description"; Name or service not known
curl: (6) Could not resolve host: "Don't; Name or service not known
curl: (6) Could not resolve host: forget; Name or service not known
curl: (6) Could not resolve host: to; Name or service not known
curl: (6) Could not resolve host: do; Name or service not known
curl: (6) Could not resolve host: this; Name or service not known
curl: (6) Could not resolve host: too.",; Name or service not known
curl: (6) Could not resolve host: "issuetype"; Name or service not known
curl: (3) [globbing] unmatched brace at pos 2
curl: (6) Could not resolve host: "id"; Name or service not known
curl: (6) Could not resolve host: "5"; Name or service not known
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (3) [globbing] unmatched close brace/bracket at pos 1
curl: (3) [globbing] unmatched close brace/bracket at pos 1

{"errorMessages":["Unexpected end-of-input: expected close marker for OBJECT (from [Source: org.apache.catalina.connector.CoyoteInputStream@694ea6e0; line: 1, column: 0])\n at [Source: org.apache.catalina.connector.CoyoteInputStream@694ea6e0; line: 1, column: 3]"

0 votes
chaitali agarwal January 2, 2018

I'm using the user name itself. 
Also, as mentioned I tried creating sub task without giving username but still I was getting same error.

Is there any other resolution for the same.

0 votes
Alexey Matveev
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.
December 29, 2017

Hello,

Make sure that you provide user name not the user display name.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 29, 2017

As the error message says, your code is not setting a valid assignee. 

You need to set it to a valid  user, one who has the "can be assigned issues" permission, or leave it out completely and make sure the global setting for "allow unassigned issues" is on.

chaitali agarwal December 29, 2017

I'm setting it to a valid user. And after your suggestion I removed assignee value from my POST data. Still getting same error. I also want to mention that I'm able to assign to that user manually.

Also, please tell me how to ensure global setting "allow unassigned issues" is ON.

Appreciate your prompt response.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 2, 2018

You clearly are not setting it to a valid user.  The error message clearly states that it is trying to use the default assignee in the project, and that user does not have the right to be assigned issues.

Go back to the basics:

What user is performing this request?  Do they have the right to assign issues?

What username are you sending?  The login id?  Is that user assignable?

chaitali agarwal January 3, 2018

The issue is resolved now. It was not because of incorrect user rather the syntax of JSON body I was sending.
I wrote assignee inside the issuetype key but it should be used outside as separate key. It worked after that.
"issuetype":
{
"id": "10"
},
"assignee":
{
"name": "username"
}

Like Dario B likes this

Suggest an answer

Log in or Sign up to answer