In this tutorial, we will demonstrate step by step guide to retrieve query parameters in Mule 4.
For example, let’s see how to retrieve the query parameters transaction_id
and transaction_type
that being sent by the client.
Retrieve Query Parameters in Mule 4
The common syntax to access the query parameters is attributes.queryParams.<<query_param_name>>
or attributes.queryParams'[<<query_param_name>>']
Step 1: Create a sample Mule project with HTTP Listener.
Step 2: Add Transform message and paste the below code.
%dw 2.0
output application/json
---
{
transactionDetails:
{
transactionType: attributes.queryParams.transaction_type,
transactionId: attributes.queryParams.transaction_id,
}
}
You can also write an expression like this,
%dw 2.0
output application/json
---
{
transactionDetails:
{
transactionType: attributes.queryParams['transaction_type'],
transactionId: attributes.queryParams['transaction_id']
}
}
Step 3: Deploy your application and make a request.

That’s simple!
Conclusion
We hope this tutorial helped you to understand how to retrieve query parameters in Mule 4. You may also like,
- How to retrieve custom HTTP Headers in Mule 4
- How to insert inbound and outbound headers without redeploying Mule app