Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get /search jql to work at all

Florian sjouw March 23, 2020

Am i sending a request to

https://recreate.atlassian.net/rest/api/2/search?jql=project=CD20015

I have tried multiple variations of this with spaces, quotes etc.
Nothing I have tried so far seems to work and everyone on the forum keeps posting it like this.

I always get >8000 results!

2 answers

1 accepted

0 votes
Answer accepted
Barry Allen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2020

Maybe we need to do URL encoding for the param "project=CD20015". can you try following link

https://recreate.atlassian.net/rest/api/2/search?jql=project%3DCD20015

 

Also, please make sure that given "CD20015" is one of your projects in https://recreate.atlassian.net/ this account .

Florian sjouw March 25, 2020

So i have identified a part of the issue, which was that the parameters were not correctly being  added.

Ah ok so I get it now, in GuzzleHttp you add parameters from an array but when passing parameters the & is added between the jql= and project= parameters thus causing the syntax error.

Problem is that you cannot add ?jql= to the end of your url because they will be overwritten by anything in the paramter url, but I have to figure something out to get it right.

Ok this works:

https://recreate.atlassian.net/rest/api/2/search?jql=project=WVEC&verify=0

This doesn't work, but this what the url in php beecomes:

https://recreate.atlassian.net/rest/api/2/search?jql=%3D&project=WVEC&verify=0

"Error in the JQL Query: Expecting a field name but got '='. You must surround '=' in quotation marks to use it as a field name. (line 1, character 1)"

I am not even using quotations in the first one and it works fine without any.

 

Anyway thanks for your help, I didn't realize I could just paste the url in the browser.
In the browser it does actually show the jql syntax error.

Like Barry Allen likes this
0 votes
Florian sjouw March 23, 2020

No that didn't change any, also notice how it just says max results 50 but still returns thousands.

{
"expand": "schema,names",
"startAt": 0,
"maxResults": 50,
"total": 8946,
"issues": [
{

.... etc

Barry Allen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2020

oops, Sorry. I assumed that you either didn't get any result at all or get >8000 results both and answered first part only.

If you want to restrict maximum results you can use maxResults param. For example If I want to get 30, then your url should be 

https://recreate.atlassian.net/rest/api/2/search?jql=project=CD20015&maxResults=30

 

But I am sure that you wouldn't get more than 50 when you didn't give the maxResults param. If you are using this backed program, please make sure that someone didn't change this param.

You can ensure that you didn't get more than 50 records by copy-pasting your url into browser(with your login) and parse that json, then count the records.

Florian sjouw March 23, 2020

But it is indicating that it already has max results on 50.

And your url still appears to not be working for me.

Do you have an example of what you use yourself?

Barry Allen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2020

>>But it is indicating that it already has max results on 50.

Yeah, agreed. Then you are getting only 50 records.

>>Do you have an example of what you use yourself?

Yeah, I have a demo project. I check the response for three different cases and every thing is working as it is.

case 1) without maxResults (got 50 issues as response)

case 2) with maxResults=1 (got only one issue as response)

case 3) with maxResults=60 (got 60 issues as response)

 

Please answer the following question to debug further.

How are you saying that you got more than 8000 results? I mean, are you counting length  of "issues" field in response json, or some other measurement?

Barry Allen
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2020

To make sure that you are getting only 50 issues as response,

Please find the total occurrences count for "project" (search along with double quotes) in your response. If you search other keys like "id","status" and etc will give you more count, because sub-resources like "priority","issuetype" also have those keys.

 

for example:

{"issues":
   [
     {"id": 101, "project":...., "priority": { "id": "priority1", "name":"Medium"}
     {"id": 102, "project":...., "priority": { "id": "priority2", "name":"High"}

}

if you search "id" you will get 4 instead of 2, because there is a sub-resource named "priority" also have the "id".
So uniq field is "project". if you search a project it will give you the valid count.

Florian sjouw March 25, 2020

-snip- move to reply

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events