Call a Rest API Action

This page is about Easy Integrations for Jira Cloud. Using Jira On-Prem? Click the On-Prem button above.

The Rest API action in Easy Integration allows you to integrate any external or internal service that supports REST calls. You can use Issue Listeners to trigger REST service calls based on specific conditions within Jira. This documentation provides details on how to configure the Rest API action and its options.

Example of an integration with Call a Rest API and Update a Jira issue action.

Prerequisites

Before you start configuring the action, ensure you have the following prerequisites in place:

  • Only Jira administrators have the necessary permissions to access and configure the Rest API action within Easy Integration.

  • Have the appropriate credentials ready for authentication, as required by the REST API you plan to integrate.

How to Configure the Call a Rest API Action

Rest API action in Listeners can be accessed within Easy Integration's admin UI. Follow these steps to configure listeners:

  1. Navigate to Jira's top menu, and click Apps.

  2. Select Manage your apps.

  3. In the sidebar, locate and click Easy Integrations configuration.

  4. Select Listeners from the app’s top menu.

  5. Configure the listener according to your requirements. For more information on that, refer to this documentation.

  6. In the Actions section of the listener configuration, click Call a Rest API.

  7. Here's how to configure the Rest API action:

    • Action name – Give a descriptive name for the action. This is a reminder for you to easily identify this action.

    • Condition – Enable or disable the condition.

      When enabled, provide a JavaScript condition for the listener. The action will execute only if the script returns true. You can refer to Context variables, Scripts, and Events for more details. For example:

      return startsWith(data.event.issue.fields.summary, 'Sultans of Swing');

    • Action parameters – Write the JavaScript to return objects of variables. For example, you can define variables like "issue key," "issue summary," "issue status," and "project name." These variables can be used in the URL, headers, and request body. Here's an example:

      var parameters = {};
      parameters['issue key'] = data.event.issue.key;
      parameters['issue summary'] = data.event.issue.fields.summary;
      parameters['issue status'] = data.event.issue.fields.status.name;
      parameters['project name'] = data.event.issue.fields.customfield_10500.name;
      return parameters;

    • URL – Enter the URL of the Rest API. Action parameters can be used as variables. In the following example, the project name is dynamic:

      https://dev.azure.com/Another-brick-in-the-code/{{project name}}/_apis/wit/workitems/$task?api-version=6.0

    • Method – Choose an HTTP method.

    • Headers – Add each header in one line, separated by an equal sign. Action parameters can be used as variables. For example:

      Accept=*/*
      Cache-Control=no-cache
      Content-Type=application/json-patch+json
      X-my-project={{project name}}

    • Authorization type – Select the supported authorization type.

    • Credential – Select the credential that is defined in the Credentials page.

    • Request body – Set the Request body if applicable. Action parameters can be used as variables. For example:

      [
        {
          "op": "add",
          "path": "/fields/System.Title",
          "from": null,
          "value": "{{issue summary}}"
        },
        {
          "op": "add",
          "path": "/fields/System.Description",
          "from": null,
          "value": "Jira issue is {{issue key}} and status is {{issue status}}."
        }
      ]

  8. Click Save, and then save your listener configuration as well.

That’s it! You have successfully configured the Call a Rest API action in Easy Integrations. To gain more insights, check out the following example:

Example 1: Create an Azure DevOps ticket with the newly created Jira Bug data

Note: This is a sample use case and can be customized to suit your integration needs.