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

Illegal character error when using applink to retrieve issues from JIRA via REST

Steve Goldberg
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.
June 29, 2014

Hi guys,

I'm trying to write a Confluence user macro that queries our JIRA instance via the REST APIs and AJAX and returns the results using the brilliant guide here: https://answers.atlassian.com/questions/209914/how-to-use-jquery-in-confluence-to-run-a-jira-rest-query-without-hard-coding-username-password-in-plain-text. The problem is that while basic JQL queries will work when I send them through the application link, I get an error back from Confluence when I try to include more complex one. My thought is that it doesn't like the inclusion of spaces in the JQL, despite trying to escape them with both "%20" and "+".

So while I can query JIRA via a URL using:

https://[CONFLUENCE]/plugins/servlet/applinks/proxy?appId=[APP ID]&path=[JIRA]/rest/api/latest/search?jql=assignee=[USER]

I get errors when I try to do:

https://[CONFLUENCE]/plugins/servlet/applinks/proxy?appId=[APP ID]&path=[JIRA]/rest/api/latest/search?jql=project=[PROJECT]%20AND%20issuetype%20=%20Bug

java.lang.IllegalArgumentException: Illegal character in query at index 91: https://[JIRA]/https://[JIRA]/rest/api/latest/search?jql=project=[PROJECT] AND issuetype = Bug
    at java.net.URI.create(URI.java:859)
caused by: java.net.URISyntaxException: Illegal character in query at index 91: https://[JIRA]/https://[JIRA]/rest/api/latest/search?jql=project=[PROJECT] AND issuetype = Bug
    at java.net.URI$Parser.fail(URI.java:2829)

Does anybody know how I can fix this?

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Eduard_Laur November 16, 2016

It looks like the https://link needs %20 as a string value. When ajax request requests a link with %20 , this is replaced with an empty space.

I managed to solve it using javascript escape funcion. Thus, I escape(escape(myquery)), getting spaces replaced with %2520 (where %25 is the escape character for %) and request is fine.

Hope it helps someone in the future.

1 vote
Jan Hordes August 21, 2014

The workaround is to replace " AND " with "%20AND%20", however this should be fixed.

Steve Goldberg
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.
August 25, 2014

Hi Jan,

As I said in my post, escaping it does nothing.

Steve

B_ Normann P_ Nielsen
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.
April 8, 2015

I have hit the same problem, did You find any solution? BR, Normann

0 votes
Steve Goldberg
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.
June 29, 2014

Seems like it could be this issue (or related to it): https://ecosystem.atlassian.net/browse/APL-1195

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events