How to write a REST API program to create a Multiple Sub-tasks for an Issue?

Can we use " for loop" in REST API program, to get Multiple Sub-tasks for an Issue ?

Below code i have used for this

REST API code:

 

{
"fields":
{
"project":
{
"key": "TEST"
},
"parent":
{
"key": "TEST-10"
},
for ( int i=1; i <=3; i++)
     {
       "summary": "Subtask-TEST10",
       "description": "Subtask of TEST-10",
       "issuetype":
           {
             "id": "10601"
           }
     }
}
}

 

For executing I used curl command:

curl -D- -u admin:admin -X POST --data "@MutlipleSubtask.txt" -H "Content-Type: application/json" http://localhost:8081/rest/api/2/issue/

 

Could someone help me with it?

And also is there any other way to do it in RESTAPI?

Thanks in Advance

 

1 answer

1 accepted

0 votes
Answer accepted
Leo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 8, 2019

Hi @Siva Anantha Satyanarayana Singamsetti ,

you may need to go with following rest api endpoint POST  /rest/api/2/issue/bulk

Refer this page for more details: https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/?&_ga=2.142165051.860651512.1572849788-2006055560.1571762377#api/2/issue-createIssues

 

BR,

Leo

Siva Anantha Satyanarayana Singamsetti November 10, 2019

Thanks Leo,  it worked.

Its a very good useful Link 

Suggest an answer

Log in or Sign up to answer