Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Best way to accept multiple values in a query parameter

I want to know the best way we can have in API to accept multiple values for a query parameter.

For example if I want to pass multiple values for a query parameter name then I can do it like -

1. <API URL>?name=a,b,c- Use some logic to from an array and take this ahead for processing.

2. <API URL>?name=a&name=b&name=c - Use some logic to from an array and take this ahead for processing.

Above are just examples and there might be more possible ways to do that.

I want to know what is the best way we can use to make use of API simpler.

Thanks,

Santosh

Solved Solved
1 5 32K
1 ACCEPTED SOLUTION

akoo
New Member

Hi Santosh,

Great question. As I'm sure you are aware, RFC 3986 (Uniform Resource Identifier (URI): Generic Syntax) doesn't cover this aspect of query parameters in section 3.4. You've identified the 2 most common ways to pass in multiple values for a query parameter.

From an Apigee Edge perspective, the main difference is that request.queryparam.<queryParamName>.values.count will be 1 for #1 and 3 for #2. To access the values in case #1, you can use request.queryparam.name directly, and in case #2 you will need to use request.queryparam.name.values. In both cases, you'll likely need to do some massaging to manipulate the data.

Aside from that, you may want to consider what is easier for your client to send to Apigee.

View solution in original post

5 REPLIES 5
Top Solution Authors