Part1-Session16|Mulesoft Telugu Tutorial|How to consume REST API in Mule|Consume REST Services Mule

Опубликовано: 07 Октябрь 2024
на канале: Mulesoft
265
1

‪@hb_mulesoftTechworld‬

In This you will learn about Connectors and How to consume REST API's/ REST services in Mulesoft

Session Content
=============

HTTP Request connector
:: It will be used as Message processor with in Flow.
Used to consume or invoke REST API's.


Employees Service details
=====================
:You may use below services:

http://hbcs-dev-employees-api.us-e2.c...

http://hbcs-dev-employees-api.us-e2.c...

http://hbcs-dev-employees-api.us-e2.c...

=======

GET http://localhost:8081/employees

Query params: deptNo is optional

Response list of employees
========
[
{
"empId": 101,
"name": "Bhagat",
"dept": 10,
"salary": 1000
}
]

From Connectors-API
=======
Use the above response and build response to below format
{
"employees":[
{
"empNumber": 101,
"empName": "Bhagat",
"deptNumber": 10,
"salary": 1000
}
]
}


POST http://localhost:8081/choice

Query params: technology -- optional
Headers: channel -- optional

Logical values to evaluate the response
technology : Mulesoft/Oracle/MySql

channel : DB

if no channel and technology values are satisfied, it will make use of Payload values and provides response.

Request Payload:

{
"drivingLicenece": "KA0123"
}

Response Text format
===
Response from Mulesoft

From Connectors-API
=======
Use the above response and build response to json format
{"message": "Response from Mulesoft"}



GET http://localhost:8081/firstsuccessful

Headers : One of the header is mandatory , sample values
channel : Wi-Fi
source : Mobile
target : Desktop

Response Text format
========
Desktop Three

From Connectors-API
=======
Use the above response and build response to below format
{"message": "Desktop Three"}