How to extend Automation for Jira with REST API calls

Still need help?

The Atlassian Community is here for you.

Ask the community

robotsnoindex

 

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

  1. 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:

    1. 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.
    2. Select Create token.
    3. Give your new token a name.
    4. 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.
    5. 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.
  2. Create your rule and add the Send web request action.
  3. Let's configure it now!
    1. First, add the API URL:

      http://myjira/rest/api/2/issue/{{issue.key}}/assignee

      (info)Note: in this case, we've used the smart value {{issue.key}} to add the issue key dynamically

    2. On the Headers field, add the name as Authorization and the value as Bearer <Personal Access Token>
      (info)Note: make sure to use the upper/lower case as shown
    3. Select the method as PUT
    4. Set the webhook body as Custom data
    5. Set the custom data as the PUT payload:
      {
        "name" : "assignee_name"
      }
      

      The action will look something like this:

  4. 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/



Last modified on Jun 3, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.