Ad

Can We Count The Number Of Query Parameters Passed Through Browser In Mule

I am trying to write a stored procedure which works dynamically. For example, If I pass three query parameters from the browser to the flow it should be assigned to the stored procedure and it should retrieve only the values from the database only for which the passed values. (Note: I am using select query in my stored procedure). I should be able to pass n number of query parameters. Could anyone assist me on this.

Ad

Answer

For your query on how to get the Query parameters key names:

Use the below expression to get the first query parameter key name. Change index value based on query parameter number.

#[message.inboundProperties.'http.query.params'.keySet().toArray()[0]]

See the below sample code that iterates over the query parameters and stores each query parameter key name into variable then prints it in logger.

<foreach collection="#[message.inboundProperties.'http.query.params'.keySet()]" doc:name="For Each"> <set-variable variableName="QueryPramKey" value="#[payload]" doc:name="Variable"/> <logger message="--- Query param kay names: #[flowVars.QueryPramKey]" level="INFO" doc:name="Logger"/>

Ad
source: stackoverflow.com
Ad