Forums

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

Create new component if it's not existing in the same request - JIRA REST API

Michael Küng
Contributor
October 10, 2019

Hi,

I am wondering if I am the first guy who is asking for that, but it seems it's maybe a special request ;)

If it's possible to create a new component by REST API, only if it's not an already existing component? This should be handeled in one request.

Is there an example available?

1 answer

1 accepted

0 votes
Answer accepted
Ravi Sagar _Sparxsys_
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.
October 10, 2019

Hi @Michael Küng 

Did you look at this link. There is an endpoint for creating a component.

Ravi 

Michael Küng
Contributor
October 10, 2019

Uh that was fast, thank you! ;)

I know this page, but unfortunately I don't understand....

{
 "fields": {
  "project": {
   "key": "TST"},
  "parent": {
   "key": "[entry.JIRAKey]"},
  "summary": "[entry.subtask1] | [entry.typecode1]",
  "description": "[entry.description1]",
 "components": [{"name": "[entry.subtask1]"}],
  "issuetype": {
   "id": "5"},
  "reporter": {
   "name": "[entry.user]"}
 }
}

At the moment, I use the code above and it's working to set the component if this is already existing, but if it's a new component I got an error message Component name 'xxxxxxx' is not valid.

The question for me was, how can I implement that the "new component" will be set?! I guess the problem is my lack of JSON knowledge... :(

Ravi Sagar _Sparxsys_
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.
October 10, 2019

How are you using the REST API? In which language?

For testing the end point you can use curl command or use the Atlassian REST API Browser or use browser plugin to test REST API.

Ravi

Michael Küng
Contributor
October 10, 2019

I use it in combination with Confluence / ConfiForms. I fire a IFTTT macro to create Jira issue (like shown in the code above). The language is JSON.

It works in general, but only if the component is already created. Now I am searching for an option to do this in one sweep e.g. create a new component if the used isn't existing.

To be honest, I am not am programmer and have less JSON knowledge, but I guess you recognized that already :D

Anyway, I appreciate that you try to supprt me in this case!

Suggest an answer

Log in or Sign up to answer