Unable to create subtasks using REST API

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 vote

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.

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.

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?

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"
}

0 vote
Alexey Matveev Community Champion Dec 29, 2017

Hello,

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

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.

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]"

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

66 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you