For a request with a multi-valued queryparam like: https://test.apigee.net?storeIds=abc&storeIds=xyz
, how can someone setup an extract variable policy so that there will be a storeIds array like: storeIds=["abc","xyz"]
?
Update #1: Using the following in javascript for Apigee:
var arrayOfStoreIds = [];
for (i = 0; i < context.proxyRequest.queryParams['storeIds'].length; i++) {
arrayOfStoreIds.push(context.proxyRequest.queryParams['storeIds'][i]);
}
Yields an error:
`Execution of script failed with error:
Javascript runtime error:
"TypeError: Cannot find default value for object ... at line ##"`
The line # referenced points to the 1st line of the for
loop
Update #2:
- Incorrect documentation at http://apigee.com/docs/api-services/reference/javascript-object-model:
context.proxyRequest.queryParams['city'].length; // == 2
- Correct syntax at https://github.com/ap-andrew/DevGuide/blob/master/javascript_new.html#L141
context.proxyRequest.queryParams['city'].length(); // == 2
So with this context.proxyRequest.queryParams['storeIds'].length()
it works! At least in javascript ... I still don't know how to do this via an extract variable policy...