How to return issues from a JQL query using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

   

Summary

You can use REST API to return issues from a JQL query. The purpose of this article is to expand on the different ways to return Jira issues using the API:

  • Performing a cURL request
  • Creating an automation rule to Send a web request


In both cases, you will need to use the Search for issues using JQL (GET) operation. As the JQL query is a request parameter for this resource, it must be URL-encoded in order to work correctly.

Encoding the JQL query

There are two ways to encode a JQL query to make it URL-compatible.

  • The first one is to perform a JQL search in Jira and copy the query from the browser's URL (after running the search). Example:
     
  • The second option is to use the URL Encoding Smart Value. Note that this option can only be used in an automation rule. Example:

    {{#urlEncode}}project = SUP and created > -5d{{/}}

Examples

Using Automation

The following examples show automation rules that use the Send web request action. For more details on how to build this type of rule please check Automation for Jira - Send web request using Jira REST API.

  • Automation rule using a manually encoded JQL query

    https://yoursitename.atlassian.net/rest/api/3/search?fields=key&maxResults=500&jql=project%3DOG%20and%20created%3E%3D%20-5d


  • Automation rule using a JQL query encoded by the URL encoding smart value

    https://yoursitename.atlassian.net/rest/api/3/search?fields=key&maxResults=500&jql={{#urlEncode}}project=OG and created>= -5d{{/}}

    • Web Response Smart Values for adding values to the Audit Log

      Jira Issue JSON URL: {{webResponse.body.issues.self}} Jira Issue Keys: {{webResponse.body.issues.key}}
    • Result from both automation rules:

Using cURL

  • cURL Request Example (Issues Created Last 7 Days)

    curl --request GET \
      --url 'https://yoursitename.atlassian.net/rest/api/3/search?maxResults=10000&jql%3Dproject%3DOP%20and%20created%20%3E%3D%20-7d' \
      --user 'youremail@mail.com:yourapitoken' \
      --header 'Accept: application/json'

Using Postman

  • Postman Request Example (Issues Created Last 5 Days)

Additional Links

Last modified on Oct 4, 2023

Was this helpful?

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