Jira API JQL-search fails with createdDate and project

Maximilian Heß July 10, 2017

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
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2017

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.

Maximilian Heß July 10, 2017

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

Running the JQL query directly via Jira works.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2017

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

Maximilian Heß July 10, 2017

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2017

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.

Maximilian Heß July 10, 2017

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.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 10, 2017

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

Maximilian Heß July 10, 2017

Yes, that should work, too.

Thanks for your investigations!

Maximilian Heß July 10, 2017

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 Sign up to answer