382
Views
2
Comments
Solved
REST: GET Hoe to pass multiple values for same parameter
Question

We are working with a REST API which is internationally defined Health interoperability standard. To search an item they define to use for AND parameters in the URL with same parameter concatenated with & and for OR one parameter with a comma delimited list, to explain some examples:

To search for a person with name=Ria AND name=Sarah the URL is:

https://URL/Person?name=Ria&name=Sarah

To search for a person with name=Ria OR Sarah the URL is:

https://URL/Person?name=Ria,Sarah

This is the same problem as explained here:

https://stackoverflow.com/questions/24059773/correct-way-to-pass-multiple-values-for-same-parameter-name-in-get-request

The format of & for AND and comma delimited for OR seems to be acceptable practice.

Currently I had to write a C# extension to do this because I could not find a way to tell the OutSystems REST how to do the AND with the same parameter repeated "name=Ria&name=Sarah". THe OR is easy because the comma delimited list is the parameter, so that is not a problem.

How can I achieve this multiple same parameter in OutSystems REST please?

2018-07-09 07-35-13
Elize van der Riet
Solution

Currently I have found this solution which seems to work, I have to still test all use cases:

I build the string with the & and multiple parameters and pass a {dummy} variable to the REST like this:

https://URL/Person?{dummy}

Where dummy is a string with value "name=Ria&name=Sarah"

This seems to work, but I have to build the string beforehand in a for loop.

2019-06-15 21-39-22
Afonso Carvalho
 
MVP

Hi Elize,

Like the Stackoverflow response mentions, this specific use case in REST APIs isn't a defined standard, but more of a convention. For reference, if your problem was reversed and you had to implement this API in Outsystems, you wouldn't be able to distinguish those two values: Outsystems would receive those two cases as "Ria,Sarah" regardless of how you'd use the input.

To my knowledge, Outsystems doesn't have a mechanism to directly map these cases, but like you discovered, you can build the query string yourself and use the separators that the API will acknowledge as AND/OR: you can still take advantage of the low code environment and not rely on an Extension.

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