How do I retrieve issues of specific status with JQL

放肆的年华 提交于 2019-12-21 20:43:23

问题


Entering a url, or running with curl, like:

https://<myurl>/rest/api/2/search?jql=project=<myproject>&status=closed&fields=id,key,status,project&maxResults=5

returns me 5 items in my project but with all statuses. For some reason I can't query for a specific status.

The output (part of it) is:

{
  "expand": "schema,names",
  "startAt": 0,
  "maxResults": 5,
  "total": 727,
  "issues": [
    {
      "expand": "editmeta,renderedFields,transitions,changelog,operations",
      "id": "79577",
      "self": "https://<myurl>/rest/api/2/issue/79577",
      "key": "<myproject>-774",
      "fields": {
        "project": {
          "self": "https://<myurl>/rest/api/2/project/<myproject>",
          "id": "14421",
          "key": "<myproject>",
          "name": "<myproject>",
          "avatarUrls": {
            (...)
          }
        },
        "status": {
          "self": "<myurl>/rest/api/2/status/1",
          "description": "The issue is open and ready for the assignee to start work on it.",
          "iconUrl": "https://<myurl>/images/icons/statuses/open.png",
          "name": "Open",
          "id": "1"
        }
      }
    },(...)
  ]
}

How to query for a given status? Many thanks.


回答1:


Use URL encoding on the attributes.

Perhaps use an online tool like this to URL encode your JQL from this:

project = PROJECTKEY AND status = Closed

to get this:

/rest/api/2/search?jql=project%20%3D%20PROJECTKEY%20AND%20status%20%3D%20Closed&fields=id,key,status,project&maxResults=5

The resulting JSON will be all closed issues.




回答2:


Run the query you want in the Issue Navigator. Use the link to the left of the Share button that resembles a chain link to find the URL for the query, e.g.

http://jira.example.com/issues/?jql=project%20%3D%20MDOAR%20and%20status%20%3D%20Closed

Use that URL with curl



来源:https://stackoverflow.com/questions/17976378/how-do-i-retrieve-issues-of-specific-status-with-jql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!