Encude URL From Rest consume call (GET method)

Encude URL From Rest consume call (GET method)

  

Hi,

I'm having a problem where i can't encode my URL for the rest service I'm consuming.

I can't share the internal rest details obviously, but i try to explain what I'm trying to achieve.

Example:
https//api.twitter.com/1.1/search/tweets.json?par1=value1&par2=value2&par3=value3

Should become this:
https//api.twitter.com/1.1/search/tweets.json?par1%3Dvalue1%26par2%3Dvalue2%26par3%3Dvalue3


----


Doing this in outsystems:
https//api.twitter.com/1.1/search/tweets.json?par1={value1}&par2={value2}&par3={value3}

Results in this:
https//api.twitter.com/1.1/search/tweets.json?par1=value1&par2=value2&par3=value3

----

When trying to use URLEncode() from HTTPRequesthandler in the OnBeforeRequest of the GET method, I have no option to encode '=' and '&' part of the url. I can only encode the parameters itself or the BaseURL,URLPath.

Any ideas how to achieve this?
I already tried to put the encoded url in the consume method as GET URL. But then Outsystems ignores my parameters.

Greetings,
Niels F.



Have you tried using https://api.twitter.com/1.1/search/tweets.json?par1%3D{value1}%26par2%3D{value2}%26par3%3D{value3} ?

Hi!
Yes! That's what i meant with:

"I already tried to put the encoded url in the consume method as GET URL. But then Outsystems ignores my parameters."


Greetings,
Niels F.

I tried to consume that URL that I put there and I had the parameters in "test" tab, what do you mean?

If you do full logging on your integrations, especially that API, you can see the HTTP trace.When using your suggestion, the HTTP requests is not taking into account the parameters, and the request will look lke this:
"https//api.twitter.com/1.1/search/tweets.json?"

That's what i meant with 'it ignores the parameters' :p
They are indeed created in service studio, and u can use them. But when requested, it ignores them. (using the HTTP trace log)

A fellow collegae said i could use one parameter which builds up the 'request' string url and afterwards encode the url.
Which results in one input parameter with the query in it.
For example:

https//api.twitter.com/1.1/search/tweets.json?{par1}
And {par1} will be filled in with for example : "UrlEncode({value1}+"&par2="+{value2}+"&par3="+{value3})"

Which might result in:
https//api.twitter.com/1.1/search/tweets.json?par1%3Dvalue1%26par2%3Dvalue2%26par3%3Dvalue3

Or something like that.
I ahve to try it out though

Ok ahah thanks for the explanation. I didn't have time to actually test it through and only tried in service studio

Keep us posted if that worked :)