With Issue Templates for Jira you’re not limited to using a template with Jira only. You can also use external software to trigger different events in Jira and apply a template immediately.
With this feature you can:
To use Apply template with REST API enable the Apply template option in global configuration - Visibility.
Use case:
Automatic tests with Jenkins are launched, but they fail. Jenkins creates a job and then a Jira issue using REST API. It applies a template afterwards, which fills necessary information and creates a structure, used by a developer and tester to fix the error.
To connect Issue Templates with external software to use API, you need to generate a token.
Go to Api Tokens tab in the global configuration of Issue Templates (Marketplace Apps>Issue Templates>Configuration>API Tokens).
Your Web Trigger URL has been generated. Don’t share the URL publicly. If you use the URL in a configuration and delete the URL later with the bin button, your configuration will stop working.
Click Generate token to create a new token for a specific user.
Create a Label and select a user that you want to generate the token for.
A token is generated for this user.
Make sure you copy and store the token, because it won’t be accessible later.
Follow these steps to use REST API (with Postman as an example). In this scenario a specific template will be applied to a specific issue.
Select GET and paste the WebTrigger URL created earlier.
Insert templateId and issueId.
issueId is the ID of an issue that you want the template to be applied to
templateId is the issue key of a template you want to use.
You can use both issuekey and issueId parameters.
Go to Atlassian documentation to find out how to check an issue ID.
Navigate to the Authorization tab.
Paste the user token that you copied when it was created.
| Status | Meaning |
|---|---|
| 200 | Accepted |
| 400 | Bad request - wrong payload (body) |
| 401 | There is no token |
| 403 | Incorrect token/invalid license |
You can use REST API with Jira Automation.
In this scenario you can apply a specific template to each new issue that is created. Follow the steps below:
issueId={{issue.id}}&templateId=10032 at the end.https://11037d47-9c1c-48c5-91dc-17f8cd51d247.hello.atlassian-dev.net/x1/pXmIy_HsDH_yyTeDmhVajNamxtM?issueId={{issue.id}}&templateId=10032
issueId is the ID of an issue that you want the template to be applied to. You can use variables, so it is applied to any new issue or input a specific ID.
templateId is the issue key of a template you want to use.
You can use both issuekey and issueId parameters.
Go to Atlassian documentation to find out how to check an issue ID.
Whenever a new issue is created the automation rule will apply template with the ID 10032 to that issue.