Forum Discussion
Hi Gursimrat,
I'd suggest taking a look at the http.request context object:
It has numerous methods for dealing with the request, including a method for getting parameters from the request. This article has an example of an endpoint that pulls in a parameter:
I hope this helps!
Hi AdamN
Thanks for your response, i am halfway in which I am able to pass the value to the endpoint via custom component, but I am somehow not able to use it inside the endpoint. Below is the change I made to the endpoint code after your suggestion.
Endpoint:
<#compress> <#assign search_query = http.request.parameters.name.get("query", "")> <#attempt> <#assign response = http.client.request("https", "abc:xyz@123.zendesk.com","/api/v2/search.json?query=%5C%22${search_query}%5C%22").get() /> <#recover> <!-- Something --> </#attempt> </#compress>
Custom Component Code to pass the value to the parameter
$.get( "${kb_endpoint_url}", { search_query : queryValue } )// where queryValue is being passed from a text box .done(function( data ) {...
When I checked in the firebug, the request was a Success but returened below reponse:
Uncaught TypeError: Cannot read property 'results' of null
Do you find any loops here?
- NicoB11 years agoLithium Alumni (Retired)
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
- Gursimrat11 years agoLeaderStill giving same error :(
- 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