2
votes

I'm unable to get issues with needed label from REST API of Jira.

I'm sending GET request to the jira_url/rest/api/2/search?jql=project=MYPROJ&label=build1. In response I get 50 random items. I know that with this label exist only 2 items, but can't get them both.
I was serfing JIRA REST API documentation, but haven't found good examples how to get issues with items in array at least. Also tried the same via POST request with body:

{
    "fields": [{"labels": ["build1"] }]
}



Tried similar examples from https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues

1

1 Answers

5
votes

Any easy way to get the JQL Query String to use is to use the Issue Search UI and look at the generated URL at the top and to just grab the jql part:

JIRA Issue Search UI

So the part to add the labels section is:

%20AND%20labels%20in%20(build1%2C%20build2)

Which is and labels in (build1, build2). It is important to note that using the & makes the REST API things the JQL query parameter has ended which is why you need to use the space encoded character of %20 and then the AND keyword to build your JQL.