# Parse message.queryparams.names variable

**URL:** <https://discuss.google.dev/t/parse-message-queryparams-names-variable/5437>\
**Category:** Apigee\
**Tags:** apigee-general\
**Created:** [August 21, 2019, 8:20pm UTC](https://discuss.google.dev/t/parse-message-queryparams-names-variable/5437 "2019-08-21T20:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [August 21, 2019, 8:20pm UTC](https://discuss.google.dev/t/parse-message-queryparams-names-variable/5437/1 "2019-08-21T20:20:39Z")

</div>

What am I doing:

Client sends request with multiple query parameters. If a parameter does not exist (key & value) I will supply them with a defaulted value. To determine if the client has sent in the correct query parameter I am using JavaScript to run the “request.queryparams.names” and will output all of the query parameters sent in by the client. I now need to parse the output of “request.queryparams.names” to determine if specific query parameter was sent.

What am I seeing:

As of right now I see the following when running “request.queryparams.names”:

```auto
request.queryparams.names [branchId, productId, customerId, shipWhseId]

```

I have tried several times to check against specific values using “request.queryparam.” but absolutely nothing gets returned. So now I am trying to parse output of “request.queryparams.names” to find out if query param name exists or not.

Any help on this would be appreciated.

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [August 21, 2019, 9:21pm UTC](https://discuss.google.dev/t/parse-message-queryparams-names-variable/5437/2 "2019-08-21T21:21:12Z")

</div>

[@Seth Dickerson](https://community.apigee.com/users/17393/sethdickerson.html)

The javascript below works

```auto
var queryparamnames = context.getVariable("request.queryparams.names");
var a = queryparamnames.toArray();
print("numOfQueryParams="+a.length);
for (var i=0; i<a.length; i++)
 { print(context.getVariable("request.queryparam."+a[i]));}

```

You can also take a look at an older post on how to parse the query parameters in JS-

[https://community.apigee.com/questions/12782/how-do-you-iterate-collection-from-requestquerypar.html](https://community.apigee.com/questions/12782/how-do-you-iterate-collection-from-requestquerypar.html)

Hope that helps

---

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [August 22, 2019, 2:26pm UTC](https://discuss.google.dev/t/parse-message-queryparams-names-variable/5437/3 "2019-08-22T14:26:53Z")

</div>

So I figured out how to do what I was looking to do with the following code block:

```auto
 context.setVariable("jsparamA", context.getVariable("request.queryparam.<defaultparamA>"))
if (context.getVariable("jsparamA") === null || context.getVariable('jsparamA') === "") { 
    context.setVariable("jsparamA", context.getVariable("<defaultparamA>"));
           }

```

knowing how “null” is being treated in regards to queryparameters within the javascript was the real issue I was having. Hope this may help someone else having a similar problem.

Thanks for all your assistance…
