Jira API JQL-search fails with createdDate and project

Jira Software version: 7.3.0

 

I cannot perform API search queries asking for "createdDate" and "project".

curl -D- -u xxx:yyy -X GET -H "Content-Type: application/json" /rest/api/2/search\?jql\=createdDate%20%3E%3D%20-30d

works, but

curl -D- -u xxx:yyy -X GET -H "Content-Type: application/json" /rest/api/2/search\?jql\=project%3DGS%20AND%20createdDate%20%3E%3D%20-30d

does not. Error is

HTTP/1.1 403 Forbidden
Date: Mon, 10 Jul 2017 10:12:46 GMT
Server: Apache
Content-Length: 226
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /rest/api/2/search
on this server.<br />
</p>
</body></html>

I suppose that it is no permission error but some kind of problem with the query.

 

Thanks in advance!

Max

 

1 answer

0 votes

Hmm.  What happens if you search just for the project and drop the date part?

i.e. just  "project = GS" or jql\=project%3DGS in the url.

This works. Changing createdDate and project does not work either.

Running the JQL query directly via Jira works.

Right, I meant specifically the url based query with just the project - does that pull back all the project issues for GS?

It returns the "first 50" setting maxResults to 50 and strting at 0. "total" returns the correct total number of issues.

So, let me repeat this back to you to ensure I have it clear:

These two calls work, pulling back issues:

  • curl -D- -u xxx:yyy -X GET -H "Content-Type: application/json" /rest/api/2/search\?jql\=createdDate%20%3E%3D%20-30d
  • curl -D- -u xxx:yyy -X GET -H "Content-Type: application/json" /rest/api/2/search\?jql\=project%3DGS

And the third call, where there are both clauses joined by an AND gives you a permission error.

Yes, exactly.

I have just found the problem: Removing the "=" from ">=-30" fixes the problem. So I transformed ">=-30" to ">-31".

Perhabs the "-" is interpreted as an assignment by the server.

Ahh, nicely spotted.  I think you might need to escape it in the url.

Yes, that should work, too.

Thanks for your investigations!

But I have a new problem...

/rest/api/2/search?jql=project%3DGS%20AND%20status%3DErledigt%20AND%20createdDate%3E-31d

does not work in my node.js Code but works via curl. It is an SSL connection so I cannot use Wireshark to analyse both streams.

Any suggestions?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,789 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot