Clone JIRA Ticket using REST API?

JJJ
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 10, 2021

i want to clone issue project A to project B via JIRA REST API.

is there any solution directly use JIRA REST API?

if no solution, I'd like to try cloning in the way below.
please give me good opinions, thank you

<second solution>
1) all ticket search from project A (using rest/api/2/search)
2) create issue to project B (using above ticket list AND using rest/api/2/issue)

3 answers

1 accepted

4 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.
May 10, 2021

Hi,

There is no api to clone issue. You need to get the data of each issue

GET /rest/api/2/issue/{issueIdOrKey}

Then create a new issue in the project B.

POST /rest/api/2/issue

https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-createIssues

JJJ
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 10, 2021

Thank you Mohamed,

i also agree :)

2 votes
Teodor Hoza February 18, 2022

/rest/internal/2/issue/issue-key/clone

Post? 

-Body "{"summary":"CLONE - test","optionalFields":{},"includeAttachments":true}"

Not found in API documentation? catch with developer console.

kriegaex September 14, 2022

This does not seem to work and yields HTTP error 404. Can you please elaborate about under which circumstances and in which Jira versions (8.22.x for me) this API can be used? Maybe you have a working example in Java or at least a curl command for the community here. I am a normal user without admin rights (only project admin) or access to whatever this developer console is supposed to be.

Teodor Hoza September 19, 2022

Hi @kriegaex This works for me in Jira Cloud, basically what I'm doing is clone an issue for test and then catch the API call that clones the issue in the browser's developer console, I'm not sure if that's the case for Jira DataCenter but you can try the steps I described above.

Like atlassian-admin likes this
kriegaex September 21, 2022

Oh OK, you just mean the browser's developer console. I mistook your hint for being about a dedicated tool for Jira developers. Unfortunately, in the data centre version of Jira, what the browser does is not so clear. It does no simply send a REST call to an internal end point like the one which seems to work in the cloud version. At least, it is not something I can easily identify in the "network" tab. Instead, it does some JS magic and XHR stuff. I do not feel so inclined to debug that with an uncertain outcome, not being a JS buff.

Anyway, thanks for trying to help me. I hope that someone else comes up with a way to do this. For now, I am using the Jira Java REST API library, for which I have hacked a simple "deep clone" for my own purposes, focusing on the fields I need to be cloned. Tha is not a generic solution, but serves my purpose. It would be better if Atlassian would expose the clone functionality in their public REST API, though.

Teodor Hoza March 29, 2023

hi @kriegaex something just crossed my mind, and I hope it can help you, you can actually make a webhook that could trigger an automation rule that clones your ticket.

Aleh Charnetski April 3, 2024

@Teodor Hoza Thank you. Works for me in Jira Cloud too.
Scriptrunner script:
def issueResult = post('/rest/internal/2/issue/[issue key]/clone')
.header('Authorization', 'Basic [your base64 endcoded user:token ]')
.header("Content-Type", "application/json")
.body([summary : "CLONE - test"]).asString()
return issueResult

Like Teodor Hoza likes this
0 votes
Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 10, 2021

Hi @JJJ,

You can also try our Jira cloud app Deep Clone for Jira.

It's possible to bulk clone thousands of issues at once and move them to other projects or instances. With the Deep Clone REST API you can automate cloning issues with your scripts.

We offer many other advanced cloning features that might be helpful for you.

Javier Gonzalez Gonzalez March 15, 2023

Hi Marlene

I'm using Deep Clone REST API to clone issues between projects.

But just single issues. Is there any way to clone a task and ALSO all its subtasks? (deep clone)

Thanks!

Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 23, 2023

Hello @Javier Gonzalez Gonzalez,

Sorry for my late reply.

I've seen that you already got feedback from our support team.

For everybody else who's reading along: When cloning with the Deep Clone REST API, it is not possible to clone an issue with all its subtasks with a single request. You need to do one request per issue. For the subtasks, you need to set parentKey as the key of the cloned parent issue. 

kriegaex March 23, 2023

@Marli, what is the point of the term Deep Clone, if you have to do it one issue at a time? If I want to copy issues manually, I can just use the regular Jira REST API.

Javier Gonzalez Gonzalez March 23, 2023

@Marlene Kegel - codefortynine it has no sense for me. You can DEEP clone using your app, but no using the API. It happens also for checklists, are not cloned for a cloned task using API.

Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 27, 2023

@kriegaex Deep Clone offers advanced features that either don't exist in Jira or require complex configuration. Over the years, Jira has made some progress in this area. For instance, it's now possible to clone attachments, which was not an option for several years as far as I know.

I've attached the Deep Clone config, so you have a better understanding what you can clone or modify with our app. Most fields can be edited in the "Field Editor", some also with Jira Expressions.

@Javier Gonzalez Gonzalez I am sorry if you experienced an issue while working with Deep Clone for Jira. If you reach out to our support, I am sure they can help you.

 

deep-clone-jira_config1.png

deep-clone-jira_config2.png

Javier Gonzalez Gonzalez March 28, 2023

@Marlene Kegel - codefortynine Deep Clone is really nice app, but it's a missfunction for us not being able to DEEP clone, subtasks and complete structure, as the app does.

Marlene Kegel - codefortynine
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 29, 2023

I'm sorry that you haven't been able to solve your use case with Deep Clone for Jira.

You could also try to automate cloning using the Deep Clone Post Function in combination with Jira Automation. If you don't want to change the status in order to clone an issue, you can work with looping transitions.

Suggest an answer

Log in or Sign up to answer