50
Views
4
Comments
Solution for passing multiple values for the same parameter Decoded in a REST call
Discussion

Hi All,

I was looking on the forum for a solution, but the solution I found seems to not work anymore in the current version of OutSystems so that's why I'm making a new post.

I am consuming a REST API that requires the following pattern: 

{URLofAPI}?Param1={valueParam1}&Param2={value1}&Param2={value2}&Param2={value3}

The problem I encountered was that if I manually defined a string in the value of Param2, it would be encoded by OutSystems, so it would look like this: "Param2={451}%26Param2%3d452" etc. I managed to solve it as follows:

I have added several same name parameters in the URL path of the API and some input matching that amount of same name parameters that will function as a maximum amount of duplicate parameters. It looks like this:

APIURL?Param1={valueParam1}&Param2 ={PARAM 2}&Param2 ={PARAM 3}&Param2 ={PARAM 4}&Param2 ={PARAM 5}

As you can see there are currently five parameters defined in the REST call which means that there is a maximum of five duplicate parameters you can pass. Then in the OnBeforeRequest you check the (if you have more parameters than the duplicate ones name and) value of the param to check if it is filled and if not you don't add it to the query parameter list of the customized request. The URL you specified before will force OutSystems to not encode the duplicate parameters because you predefined them in the URL path.

2023-12-16 19-57-03
Sanjay Kushwah

Hi @Bart van Orizande,

Could you please clear more your point where you are facing issue? In above description i understand that you are defining multiple parameters in your URL and it they can be duplicate as well.


Kind regards,

Sanjay Kushwah

UserImage.jpg
Bart van Orizande

Hi Sanjay, 

I'm not facing an issue, I'm posting the solution to an issue I was having that I solved and thought it would be beneficial for others as well so I made this post as explained above.

2023-12-16 19-57-03
Sanjay Kushwah

Could you attach a sample OML so we can see exact code as well ??


UserImage.jpg
Bart van Orizande

Because it is a customer's IP I can't share the module itself but I made a sample OML that shows the solution within a Service Studio environment

SampleMultipleSameParamsAPI.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.