Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JQL with rest

Gilad Baruchian November 10, 2014

Hello,

I am trying to run a jql query using rest with java to get all issues from project "RO" and in a status I give as a parameter.

When I give a status without spaces everything works great, but when I give status with spaces (like In Review) i get:

Server returned HTTP response code: 400 for URL: http://myServer:8080/rest/api/2/search?jql=project%20%3D%20RO%20AND%20status%20%3D%20In+Review

 

seems like its a encoding problem, it doesn't encode the space right, i also tried %22 and it didn't work.

here is a part of the code:

String encoded = URLEncoder.encode("project = "+project+" AND status = " + status);
status = URLEncoder.encode(status,"UTF-8");
URL url = new URL(BASE_URL + "search?jql=project%20%3D%20"+project+"%20AND%20status%20%3D%20" + status);

How can I encode it correctly?

 

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Geert Graat
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.
November 10, 2014

Hi,

If I just look at the URL, I see it lacks the quotes (") around the status. So it should be something like this:

http://myServer:8080/rest/api/2/search?jql=project%20%3D%20RO%20AND%20status%20%3D%20"In%20Review"

You can use the issue navigator to see how the query is encoded in your case.

BTW I noticed you have In+Review instead of In%20Review, both seem to work when surrounded with quotes. The %20 version is what you see in the issue navigator.

Regards,

Geert

0 votes
Gilad Baruchian November 10, 2014

Works like a charm, thank you Geert!

TAGS
AUG Leaders

Atlassian Community Events