How to return issues from a JQL query using REST API

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

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

   

要約

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{{/}}

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

最終更新日: 2023 年 10 月 4 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.