Get Started with MuleSoft : Hello World Application

Build your first API in MuleSoft

In this blog we will cover the steps to create a hello world rest api in Mule 4:

Pre-requisite: Anypoint Studio 7.2 or above

                         Mule Runtime 4.1.5 or above

Step 1:

Create a Mule Project in Anypoint Studio. Go to File->New->Mule Project

Step 2: 

Name the project appropriately and select the Mule runtime to be used for execution.

Step 3:

The new project gets created and by default the control points to a mule configuration file where one can drag & drop different Mule Components to achieve the business requirement.

Step 4: 

On the right-hand side there is a component palette where we have different modules and different operations under each module.

Step 5:

Drag & drop HTTP Listener on message flow. Double click on http listener component to complete he configuration. The listener component when dropped on message flow inherently becomes part of the mule flow. Mule flow is a core component which helps in orchestrating different mule components.

Step 6: 

Click on + button in connector configuration & change the default port 8081 to a different one if it’s already occupied. Click on Ok.

Step 7:

Populate the path for the api. This gets appended with the host, port while calling the api.

Step 8:

Select the Set Payload component from the component palette. This component is part of core module.

Step 9:

Drag & drop the component in mule flow. Double click on set payload component.

Step 10: 

Select the value to literal mode and populate the value as “helloworld”. Save all the files.

Step 11:  

Deploy the Mule application by right clicking on mule project-> Run As -> Mule Application

Step 12:

In the logs we get a success message indicating successful deployment of api.

Step 13:

Go to postman and test the api by populating the endpoint.

http://{localhost} : {port}/{path}

Step 14:

Click on Send button to test the api

Leave a Reply

Your email address will not be published. Required fields are marked *