How to create JIRA issue ticket from a template using REST api?

I want to create JIRA Change Request Ticket using a template. 

Below is the format of the data sent to JIRA. I have tried using the projectTemplateKey parameter along with this request. But I am not sure if this is the right way. 

Could anyone please help? 

payload =
project: { key: "CRQ"},
customfield_15630: "SampleTemplateName",
summary: "Testing",
customfield_17679: "N.A" ,
customfield_14530:"2018-06-17T00:00:00.0+0000 ",
customfield_14531: "2018-06-17T00:00:00.0+0000 " } }


3 answers

2 accepted

2 votes
Accepted answer

I'm not sure what you mean by "template".  Your call to create an issue looks ok to me, so I'm not sure what's going wrong.

The xml you've given is of no use for REST calls, so I'm guessing I am missing some part of a process you are going through that you've not explained.

As an aside, projectTemplateKey is not a parameter I recognise, could you explain where you found it in the REST API docs and what you think it does?

The JIRA Change request has a field called 'Template' , so when it is selected some fields are automatically populated and related services and subtasks are created along with the ticket.

So I am trying to create a ticket from a template using REST API.

But when tried to add the template value as below, 

customfield_15630: "SampleTemplateName",


Error message from the JIRA response

400 Bad Request: {"errorMessages":["We can't create this issue for you right now, it could 
be due to unsupported content you've entered into one or more of the issue fields.
If this situation persists, contact your administrator as they'll be able to access more
specific information in the log file."],"errors":{}}

I would like to know if creation of ticket from template is possible using REST api ?


I found the projectTemplateKey parameter from here. Not sure if it is related.

Do you mean that you want to create a  Service Desk Request? Then you should use Jira Service Desk API to create a request.

That is how you should create it

The post you linked to your message is about project templates. They do exists in Jira. Project templates let administrators create projects with certain workflow schemes, screen schemes etc. You do not need it.

Ah, I think that helps me understand the problem.

You are NOT trying to create an issue from a "template", you have a field that has some hacks on it that manipulate the user's browser into filling fields for them.

You have not configured REST calls to do the equivalent in background code.

In reality your "template" field is simply a custom field.  Your REST call is not replicating all the logic you've set up in your template hack, so it's failing.

If you re-read the link you've given again, you should see that the projectTemplateKey is a function of creating projects.  Projects are not issues.

If I'm not mistaken, you're using Issue Templates - that's why @Alexey Matveev [cPrime]and @Nic Brough [Adaptavist] were a bit confused :)

The error message that you've attached was related to a bug, when more than one app's post function were stacked and conflicted with themselves. This has been fixed recently - simply update the app at the Marketplace, and the error should be gone.

Your payload is lacking an issueType parameter, which is required for Jira to create an issue. The templateProjectKey parameter is related to project templates, not issue templates.

Here's an example of a proper issue creation from a template via REST API:

2 votes


What REST API do you use? What is project template key?

I use JIRA API endpoint '/rest/api/2/issue' . 

<item><title>[TMPL-167] NTW-8 [Network_Interface_configuration]</title><link></link><project id="15980" key="TMPL">Templates</project><description>Test</description><environment/><key id="492895">TMPL-167</key><summary>NTW-8 [Network_Interface_configuration]</summary> 

Here's the xml format of the template I want to use for the ticket. 

Kindly try to answer @Nic Brough [Adaptavist]question about the template. I also can not figure out what you are up to with the template.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

168 views 4 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you