I'm trying to use a cql query in an Ajax GET to get some search suggestions. So far it works for a single word (like below), and returns 5 suggestions as intended.
http://<myurl.com.au>/rest/api/content/search?cql=text~wifi&limit=5&type=page
However any spaces I add to the search end up double encoding the spaces as %2520 and cause the query to fail with the following error:
http://<myurl.com.au>/rest/api/content/search?cql=text~wifi%2520network&limit=5&type=page
"message":"Could not parse cql : text~wifi%20network"}
Is my syntax for the request wrong? How can I handle spaces/multiple words better? I'd be happy to share more of my code if its relevant.
@Foti MougosYou should try like this
http://<myurl.com.au>/rest/api/content/search?cql=text~"wifi network"&limit=5&type=page
I think you are missing the quotation mark double quotation mark " "
see here also for some other example https://developer.atlassian.com/server/confluence/performing-text-searches-using-cql/
best regards,
Hi Moses,
Thanks for the reply, unfortunately this didn't work:
https://<myurl.com.au>/rest/api/content/search?cql=text~%2522wifi%2522&limit=5&type=page
Unfortunately the quotations are still getting double encoded as %2522 when they reach the server.
My javascript that builds the URL and passes it to the Ajax is below, I've tried both using quotes explicitly and using the encoded %22.
var searchURL = 'http://myurl.com.au/rest/api/content/search?cql=text~%22' + text + '%22&limit=' + limit + "&type=page";
OR
var searchURL = 'http://myurl.com.au/rest/api/content/search?cql=text~"' + text + '"&limit=' + limit + "&type=page";
If I copy paste the URL with %22 I don't get any errors. I'm just not sure what is double encoding the quotation marks or spaces in my request. Do you have any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.