The goal of this article is to help to build out-of-box solutions with Automation for Jira (A4J) and Jira REST API. We will cover how to send a REST API through A4J. This will be useful to automate a REST API action. For instance, when an issue will be created, we can add a new field option into a field type e.g: "Select List (single choice)".
We would like to point out that using Jira REST API with A4J opens many opportunities to build great workarounds to resolve possible issues. :)
We will cover the trickiest part of this rule, which is the REST API configuration. Considering this, let's follow the steps below. We'll explain how to make this as we go:
1. We need to generate the API token associated with your Atlassian account within Jira. For this, we can follow this documentation: API tokens - Atlassian Documentation.
2. Then we need to encode the credentials "<EMAIL>:<API_TOKEN>" with base64. We can make this through any online tool like Base64 encode.
Note: Make sure not to include a line break at the end.
Apart from that, it's possible to Encode to base64 through terminal:
$ echo -n "email@example.com:<YOUR_TOKEN_HERE>" | base64
3. Into the rule action, we can use all Jira REST API available in Jira: (The Jira platform REST API).
E.g.: https://<jira_instance>/rest/api/3/customField/10287/option
Make sure to include the entire instance URL: my-instance-.atlassian.net.
4. Add the Headers with Authorization Basic "<EMAIL>:<API_TOKEN>" encoded to base64.
E.g.: Authorization Basic HzxuhHbhzhdjasYTgdjGfrGHzxuhHbhzhdjasYTgdjGfrG
5. HTTP method: in this case, we'll send the web request by POST, however, it's possible to use other methods like GET, PUT, DELETE.
6. Webhook body: select Custom data to be able to send the JSON data.
7. Then, in "Custom data" we can add the JSON payload.
Example from Jira REST API:
Send web request example:
Note: Select the option “Delay execution of subsequent rule actions until we've received a response for this webhook" if you want to receive the answer into {{webhookResponse.status}}. With this log action below, the webhook response will be printed on the audit log.
Hope that this article helps everyone! :)
Cristiano
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
63 comments