Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JIRA REST API: How To Query on the fixVersions Field

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?

like image 767
Steve Murphy Avatar asked Sep 01 '14 18:09

Steve Murphy


People also ask

Can Jira call REST API?

Authentication for REST API requests Jira Service Management uses cookie-based authentication in the browser. Therefore, you can call the REST API from JavaScript on a page and rely on the authentication that the browser has established.

How does Jira REST API work?

Jira REST APIs provide access to resources (that is, data entities) via URI paths. To use a REST API, your application makes an HTTP request and parse the response. Currently there are two API names available, which will be discussed later on this page: auth: – for authentication-related operations.


1 Answers

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
like image 96
luviktor Avatar answered Sep 19 '22 17:09

luviktor