How to extend Automation for Jira with REST API calls
Summary
Not all of Jira REST API methods are available on Automation for Jira as actions - but we have the Send web request, that can be used to call REST APIs!
We'll use Jira as the destination, but any tool that accepts Personal Access Tokens is compatible too.
Solution
In this example, we'll assign an issue to an user
Create Personal Access Token in the application
All users are allowed to create their own PATs, which will match their current permission level. To create the tokens, you may follow these steps:
- In your Jira application:
- Select your profile picture at the top right of the screen, then choose Profile. Once you access your profile, select Personal Access Tokens in the left-hand menu.
- Select Create token.
- Give your new token a name.
Optionally, for security reasons, you can set your token to automatically expire after a set number of days.
The EXPIRES SOON status appears 5 days before the actual expiration date. Once the token expires, you can't reactivate it. You must create a new token.Click Create.
Your personal access token is created. Copy the token and store it in a safe space.
You won’t be able to see your token again once you click Close.- In your Jira application:
- Create your rule and add the Send web request action.
- Let's configure it now!
First, add the API URL:
http://myjira/rest/api/2/issue/{{issue.key}}/assignee
Note: in this case, we've used the smart value
{{issue.key}}
to add the issue key dynamically- On the Headers field, add the name as
Authorization
and the value asBearer <Personal Access Token>
Note: make sure to use the upper/lower case as shown - Select the method as PUT
- Set the webhook body as Custom data
- Set the custom data as the PUT payload:
{ "name" : "assignee_name" }
The action will look something like this:
- Publish and test!
For more details on Jira's REST APIs: https://developer.atlassian.com/server/jira/platform/rest-apis/
More about Smart Values at https://support.atlassian.com/jira-software-cloud/docs/what-are-smart-values/