Playing with Query Params using WSO2 Property Mediator.

We can invoke APIs using a request payload or sending them in the URL as query parameters.

We can do several operations using the property mediator with the query parameters.

Verify if the query params exist in the URL.


You can further read about Query Parameters from this doc.

Let’s look at the following scenario. Assume the user enters the customer name, term, and loan amount in the request as above. As the output, he needs to have calculated the monthly installment amount which should be paid to the bank.

We can access query params as get-property(‘’). We can get the boolean value of it as boolean(get-property(‘’)).

If the name exists in the URL as query param it will output true else false. We can combine two or more expressions using and operation as shown above.

Calculations using Property Mediator.

As per our use case, we need to do a calculation based on the loan term and the loan amount.

monthly installment = round value of ((amount/term)*1.17)/100

It is done in the property mediator as below. As per the use case, I’m doing this in the args expression.

You can refer to the complete XML Configuration as below.

In the above API, first, it checks if all the query parameters exist in the URL. If yes, it will go to the true case in the switch mediator. It will create a Payload using the Payload Factory mediator.

After deploying the API, open any of your browsers and paste the below URL in the tab.


It will provide an output as below.

Bank info for customer isruu about loan amount 250000 EUR in term 30 months: 9750.0 EUR

Senior Software Engineer — QA at WSO2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store