How to Retrieve Query Parameters in Mule 4

How to Retrieve Query Parameters in Mule 4

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.

retrieve query parameters in mule

That’s simple!

Conclusion

We hope this tutorial helped you to understand how to retrieve query parameters in Mule 4. You may also like,

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.

retrieve query parameters in mule

That’s simple!

Conclusion

We hope this tutorial helped you to understand how to retrieve query parameters in Mule 4. You may also like,

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related Articles

How to Create Multiple Folders at Once in Windows 10

Creating folders and subfolders manually is time consuming tasks...

How to Integrate Solace with MuleSoft using JMS API

In this tutorial, we will demonstrate step by step...

How to Open Port on AWS EC2 Instance

In this tutorial, we will demonstrate step by step...

LEAVE A REPLY

Please enter your comment!
Please enter your name here