Creating sub-task from an existing issue using API

mb cebrian January 20, 2020

I know this has been asked countless of time. Unfortunately I still can't get it to work. So my apologies in advance. 

 

I'm trying to create a sub-task from an existing EPIC ticket which has a key value of ABC-123. My curl command is below. 

curl -D- -u user:user -X POST --data {"fields":{"project":{"key":"ABC-123"},"summary":"Sub-task of ABC-123","description":"Don't forget to do this too.","issuetype":{"id":"5"}}} -H "Content-Type:application/json" https://localhost:8080/rest/api/2/issue

 

..and this is the error I'm getting

{"errorMessages":["Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@5db919f1; line: 1, column: 3]"]}

1 answer

1 accepted

0 votes
Answer accepted
Mohamed Benziane
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 20, 2020

Hello @mb cebrian 

Welcome to the community.

Can you try this code below :

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

 

Look if your issuetype id for subtask is correct. The project key in your code look wrong for me. The parent is missing too.

 

Hope this helps

mb cebrian January 20, 2020

hello. how do I get the correct issuetype id?

Mohamed Benziane
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 21, 2020

Hello,

here the doc to find the issuetype id:

https://confluence.atlassian.com/jirakb/finding-the-id-for-issue-types-646186508.html

 

But you can try this:

issuetype={"name":"Story"}

instead of :

"issuetype":
        {
            "id": "5"
        }

Hope this helps 

mb cebrian January 21, 2020

Thanks @Mohamed Benziane 

I was able to get it to work. Worth noting as well that I had to enclose 

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

Suggest an answer

Log in or Sign up to answer