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 vote

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published 31m ago in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

9 views 0 3
Read article

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