N0xus
N0xus

Reputation: 2724

Jira Rest API JQL query

I'm making use of the Jira API with the following call:

https://site.url/rest/api/2/search?jql=project=PROJECT&updated>=startOfWeek(-1w)

When I run this, I'm getting over 6000 results. But when I run the jql query of project = PROJECT AND updated >= startOfWeek(-1w) inside of my Jira sites search bar, I only get around 60 results.

Is there something I'm missing in my api call that would limit the returned to the data to the above query?

Edit Looking further it appears my call is only bringing back results from my project space and not using the updated query. What should I do so it picks up both?

Upvotes: 2

Views: 12144

Answers (2)

David Bakkers
David Bakkers

Reputation: 535

There is a typo in your query. You have used an ampersand instead of the word 'and'. The ampersand is the character used to add query parameters, so you effectively did this query

https://site.url/rest/api/2/search?jql=project=PROJECT

then Jira just ignored what came after the ampersand, as it didn't know what the parameter 'updated>' was, or how to make it equal 'startOfWeek(-1)'

Within the JQL, you must use the word 'and' with spaces before and after, like this:

https://site.url/rest/api/2/search?jql=project=PROJECT and updated>=startOfWeek(-1w)

Only use ampersands to add other query parameters afterwards, like this:

https://site.url/rest/api/2/search?jql=project=PROJECT and updated>=startOfWeek(-1w)&startAt=0&maxResults=500

Upvotes: 4

Pradeep SJ
Pradeep SJ

Reputation: 2374

Please send the API as POST method:

API: https://url/rest/api/2/search
Body:

{
"jql": "project='project name'&updated>=startOfWeek(-1)"
}

Upvotes: -1

Related Questions