JIRA REST API: How To Query on the fixVersions Field

Steve Murphy picture Steve Murphy · Sep 1, 2014 · Viewed 7k times · Source

I need to use the JIRA REST API to return issues with 15824 as the value of id in the fixVersions field. As you might know, that field is an array and can contain more than one version. My results are expected to have at least one element, sometimes two. Here is a sample with one version:

"fixVersions": [

      {
        "self": "https:\/\/aDomain\/rest\/api\/2\/version\/15824",
        "id": "15824",
        "name": "2014-08",
        "archived": false,
        "released": false
      } ]

Here is a sample with two versions:

"fixVersions": [
{
    "self": "https:\/\/domain\/rest\/api\/2\/version\/16011",
    "id": "16011",
    "description": "ae426557c89782c8446b03b0eacaef649373b10a",
    "name": "2.2.0",
    "archived": false,
    "released": true,
    "releaseDate": "2014-08-31"
},
{
    "self": "https:\/\/domain\/rest\/api\/2\/version\/15824",
    "id": "15824",
    "name": "2014-08",
    "archived": false,
    "released": false
}

]

Regardless of the number of fix versions, the issues I want will always have 15824 as the id.

I tried this query:

/rest/api/2/search?jql=project=MYPROJECT&fixVersion=15824&fields=id,key,fixVersions

But that returns issues with other fixVersions, and sometimes issues with no fix versions assigned.

Can you help me?

Answer

luviktor picture luviktor · Sep 1, 2014

When you specify ths JQL part of your request, don't use & sign but use the JQL syntax (AND) to specify multiple conditions.

& sign only splits the query string parameters of the request. These are the possible query string parts:

  • jql
  • startAt
  • maxResults
  • validateQuery
  • fields
  • expand

So your proper request should be

/rest/api/2/search?jql=project=MYPROJECT and fixVersion=15824&fields=id,key,fixVersions