Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira REST API : Creating an issue

Shiv Kumar May 20, 2020

Hi All,

I have recently started interacting with JIRA Rest APIs and I am simply trying to create an ISSUE for a particular PROJECT.

I get a response which specifies what issue types exist in the project, and I try to use the TASK with id 10002 as the parent for the issue I am trying to create.

Here is the response I get about the project for reference,

Screenshot 2020-05-21 at 9.36.43 AM.png

But when I do this, I get the below response.

{    "errorMessages": [],    "errors": {        "project": "Sub-tasks must be created in the same project as the parent."    }}

In both these calls, the project Id is the same.

Can someone please suggest what can be done here?


Much thanks.

1 answer

1 accepted

1 vote
Answer accepted
Benjamin
Community Champion
May 20, 2020

Hi @Shiv Kumar 

 

 Please share the aPI call details you use, so it can be use to correlate with the error message presented. 

 

Issue type ID is just the the ID to identify what issue type you are using. Base on the error message you are using sub-task issue type(10003) but did you map the newly created sub-task with the actual ID of the unique task you created. That ID is not 10002

Shiv Kumar May 20, 2020

Hi @Benjamin, here are the call details:

APIhttps://xompany.atlassian.net/rest/api/3/issue
type : POST
body : {
"update": {},
"fields": {
"summary": "Testing JIRA API",
"parent": {
"id": "10002"
},
"issuetype": {
"id": "10003"
},
"project": {
"id": "10100"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Order entry fails when selecting supplier.",
"type": "text"
}
]
}
]
},
"labels": [
"JIRA"
]
}
}

Nic Brough -Adaptavist-
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.
May 23, 2020

What is the issue key of issue 10002 and what is the key of project 10100 ?

Shiv Kumar May 25, 2020

project key: 'SUP',

issue Name: 'Task' //issue does not have a key, but has a 'name' attribute.

Nic Brough -Adaptavist-
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.
May 26, 2020

That's not right.

An issue always has a key, they don't exist without them (or if they do, your database is fried).  We need to see the Key of issue 10002.

Shiv Kumar May 26, 2020

An Issue does, yes. But I am trying to use An Issue Type as the parent, and this issue type does not have a key. 
The image on top shows the issue type 10002 that I am using as the parent for the issue that I am trying to create.

The attachment shows the request body.
Screenshot 2020-05-26 at 5.20.23 PM.png
If I am doing this wrong all-together, pls do suggest the right way with an example possibly?


Thanks again!

Nic Brough -Adaptavist-
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.
May 26, 2020

Ok, I think you are misunderstanding the issue/sub-task relation.

An issue type can not have sub-tasks. They're not issues, they are an attribute of an issue.   Only an issue can have sub-tasks.

You appear to be trying to attach a sub-task to an issue type.  Where you're using issue: 10002, that's probably an existing issue in another project, hence the error message.

Try attaching the subtask to an issue in the SUB project.

Shiv Kumar May 29, 2020

Hi Nic,

Yes, you are right.
I had misunderstood it.

I had to do Sub-task->Task.
But instead I was doing Sub-task->Issue Type.

 

Thanks for pointing it out.

Suggest an answer

Log in or Sign up to answer