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

howto : quotes in confluence ajax request using jira application link

kevin anderson October 8, 2013

for an external gadget I am workin on I need to submit a jql query to our jira host, which sits in another domain from the confluence box where the gadget will run

using the method defined here where an application link is used for cross domain ajax requests between confluence and jira, I have setup the code to properly query the jira host for simple api requests

where my problem begins is when i need to perform a jql search and the parameters are quoted

http://confluence.example.com:8090/confluence/plugins/servlet/applinks/proxy?appId=63423b48-3d19-30e7-97e6-950290b76667&path=http://jira.example.com/rest/api/2/search?jql%3Dproject%3Depdc%2Band%2BfixVersion%2Bin%2B%28\%22Version%201.0\%22%29

( decoded : jql=project=epdc+and+fixVersion+in+(\"Version 1.0\") )

i get the following error from the confluence rest api:

java.lang.IllegalArgumentException: Illegal character in query at index 108: http://jira.example.com/http://jira.example.com/rest/api2/search?jql=project=epdc+and+fixVersion+in+(\"Version 1.0\")

at java.net.URI.create(Unknown Source)

as a side note...the query works fine when run directly against the jira host in a browser

http://jira.example.com/rest/api/2/search?jql%3Dproject%3Depdc%2Band%2BfixVersion%2Bin%2B%28\%22Version%201.0\%22%29

So.....

I need to be able to submit complex jql across the application link, but i cannot wrap my head around how to get the quoted content to pass through the confluence rest api for the application link

Any ideas?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
kevin anderson October 20, 2013

so far my only recourse is to force users to save a jql filter in jira and then leverage that in the gadget application instead of allowing "in gadget" jql construction

1 vote
kevin anderson October 9, 2013

Charles:

I made the adjustment to the url and removed the escapes ... still yileds the crash:

http://confluence.example.com:8090/confluence/plugins/servlet/applinks/proxy?appId=63423b48-3d19-30e7-97e6-950290b76667&path=/rest/api/2/search?jql=project%3Depdc%2Band%2BfixVersion%3D%22Version%201.0%22

(decoded params: search?jql=project=epdc+and+fixVersion="Version 1.0")

Result:

Oops - an error has occurred

Cause

java.lang.IllegalArgumentException: Illegal character in query at index 77: http://jira.example.com/rest/api/2/search?jql=project=epdc+and+fixVersion="Version 1.0"
at java.net.URI.create(Unknown Source)

caused by: java.net.URISyntaxException: Illegal character in query at index 77: http://jira.example.com/rest/api/2/search?jql=project=epdc+and+fixVersion="Version 1.0"
at java.net.URI$Parser.fail(Unknown Source)

Stack Trace:[hide]

java.lang.IllegalArgumentException: Illegal character in query at index 77: http://jira.example.com/rest/api/2/search?jql=project=epdc+and+fixVersion="Version 1.0"
	at java.net.URI.create(Unknown Source)
	at com.atlassian.sal.core.net.HttpClientProtocolConfig.changeHostConfigurationProtocol(HttpClientProtocolConfig.java:44)
	at com.atlassian.sal.core.net.HttpClientProtocolConfig.configureProtocol(HttpClientProtocolConfig.java:21)
	at com.atlassian.sal.core.net.HttpClientRequestFactory.configureProtocol(HttpClientRequestFactory.java:85)
	at com.atlassian.sal.core.net.HttpClientRequestFactory.getHttpClient(HttpClientRequestFactory.java:56)
	at com.atlassian.sal.core.net.HttpClientRequestFactory.createRequest(HttpClientRequestFactory.java:45)
	at com.atlassian.sal.core.net.HttpClientRequestFactory.createRequest(HttpClientRequestFactory.java:17)
	at sun.reflect.GeneratedMethodAccessor897.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
	at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
	at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)

0 votes
kevin anderson October 20, 2013

this is still an outstanding problem.. I cannot submit jql to jira through the application link via REST api where the JQL contains special charcters such as quotes...any one have any ideas how to resolve this problem?

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 Kevin,

I seem to be having the same problem as you. Did you ever fix this?

Steve

kevin anderson July 5, 2014

I had to force the users to craft their JQL in jira and save it. Then I built an interface in my plugin that allowed them to do a search by filter ID.

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.
July 6, 2014

Thanks. I feared that was the only workaround.

0 votes
CharlesA
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.
October 9, 2013

I can see two problems here.

  1. Backslash is listed as an "unwise" character in RFC2396 because many URL parsers either break on it completely or randomly turn it into a forward slash without telling you. This is the cause of the "Illegal character in query" message. Browsers tend to be more lenient about malformed URLs, which is why it works when put directly in your browser.

    If the backslash is necessary, you should %ge-escape it in the parameter. That said, from looking at the JQL your backslash shouldn't be necessary at all - it's not escaping any quote that needs escaping. Try removing it from the query entirely?
  2. The applinks proxy is prepending the application's base URL to the path you're trying to proxy. You want to supply a path relative to the base URL of the JIRA instance, rather than to its absolute URL.

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