Create API in Mulesoft

Mulesoft is an integration tool that is used to create APIs. Mulesoft recommends following API-led connectivity to create APIs. This connectivity consists of 3 layers which are described below

In this article, we will see how to create a simple API in the Mulesoft Integration tool.

Creating API in Mulesoft Integration Tool

We will create a basic API to pass the payload and get the same payload as a response. Here, we will create the Integration application without using Maven.

create mulesoft 4 api

The following image shows you an overview of the flow in Mule 4 any point studio.

Run the Mule 4 API

On the toolbar, click on the Run -> Run configurations -> General -> select this API and run it. This will deploy the API in your local machine.

Once the API is deployed, you can test the application through the postman client app.

Testing Mule API through PostMan

After deploying the API, you can test it through the postman tool. In the postman, enter localhost:8081/test in the address bar, change the method type to POST and enter the below request in the body of the payload

{
  "name": "bigdataers"
}

Hit Send button in the postman and get the same response as the request. The postman curl command is shared here for your reference

curl -X POST 
  http://localhost:8081/test 
  -H "cache-control: no-cache" 
  -H "content-type: application/json" 
  -H "postman-token: 8c75bc25-a339-f225-29fc-9cbf24ea6637" 
  -d "{
	"name": "bigdataers"
}"

I hope, this article will help you in creating a basic mule application in any point studio, running it, and testing it using postman. In case you get any error during deployment, then you can contact me.

This API was created without using the maven. In real-time projects, all mule applications use Maven for project dependencies, building and deploying applications. We will cover maven in future articles. In my next article, I will show you how to use the transform component with multiple examples.