Forum Discussion
Hi Gursimrat
can you try to replace the URL with this?
<#assign response = http.client.request("https", "abc:xyz@123.zendesk.com","/api/v2/search.json?query='${search_query}'").get() />
I think the issue is that the http.client is always trying to encode your URL so if you specify an encoded query you will get a double encoded one :)
This is just a guess though..
Thanks,
Nico
- NicoB11 years agoLithium Alumni (Retired)
Hi Gursimrat
could you please post the code in your <#recover> section?
What I don't understand is where you are trying to access the results variable since I cannot see any such variable in your code and I think that's where the issue is happening.
Thanks,
Nico
- Gursimrat11 years agoLeader
Hi NicoB
results are basically the JSONP response I am trying to read. And adding the code to recover didn't help.
{"count":1,"results":[{"result_type":"article","position":0,"comments_disabled":false,"label_names":[],"vote_sum":0,"locale":"en-us","section_id":200164994,"url":"https://community-name.zendesk.com/hc/api/v2/articles/200820164-What-are-these-sections-and-articles-doing-here-.json","id":200820164,"html_url":"https://community.zendesk.com/hc/en-us/articles/200820164-What-are-these-sections-and-articles-doing-here-","draft":false,"source_locale":"en-us","title":"What are these sections and articles doing here?","updated_at":"2014-02-07T23:46:17Z","promoted":false,"name":"What are these sections and articles doing here?","created_at":"2014-02-07T23:46:17Z","translation_ids":[201089774],"author_id":243252074,"vote_count":0}],"previous_page":null,"facets":null,"next_page":null}
Workflow is as below:
From a text box in the custom component, when a user enters a query, and on the click of the search button, the parameter will be passed on to the endpoint. The endpoint will then call the external zendesk API via http request and the returned results will be served to custom component which will display them on the forums.
- NicoB11 years agoLithium Alumni (Retired)
It might not be the cause but I noticed that while in the endpoint you're looking for a "query" parameter:
<#assign search_query = http.request.parameters.name.get("query", "")>
in your JavaScript code it seems like you're passing a parameter with name "search_query":
$.get( "${kb_endpoint_url}", { search_query : queryValue } )/