Articles in this section
Category / Section

Create REST API Using Data Integration Platform

2 mins read

Introduction:

 This article explains about creating REST API using the Data Integration Platform and fetch data from the database table.

Steps Involved:

Using the Syncfusion Data Integration Platform:

  1. Start an HTTP Server on any port.
  2. Use the Execute SQL processor to fetch the records from the database.
  3. Send the HTTP response in JSON format.

Overall Workflow:

overall workflow

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Step 1:

 Start an Http-Server on any port by configuring the listening port of HandleHttpRequest processor.  Enable the StandardHttpContextMap controller service for the HTTP Context Map. Configure the allowed paths where the Http request will be communicated.

HandleHttpRequestProcessor

 

Step 2:

Drag the ExecuteSQL processor and configure the DBCPControllerService for the processor as shown in the following image.

DBCP Controller Service

Give the SQL Select query with the where clause parameter that should be passed dynamically from the URL as follows:

Note:

 

Ensure you have the table from that you are going to query the database.

 

 
Execute SQL

The Output of the ExecuteSQL processor will be returned in Avro format so the ConvertAvroToJson processor can be used to send the Http Response as a JSON Value.  

Step 3:

In the ConvertAvroToJson processor configure the JSON container options when the output response should be sent as a JSON Array.

Handle Http Response

Step 4:

Configure the HandleHttpResponse processor to send the response to the client from your database server.

Http Response

Step 5:

Open your Chrome browser with the following URL Pattern,

http://localhost:<port>/<path> ?<queryparameter

Port:  The port number you have configured on the HandleHttpRequest processor.

Path: The allowed path provided in the HandleHttpRequest processor.

Query Parameter: The value that is to be passed to the server to fetch the record from the database.

Open your Chrome Browser and type the URL specified in the above format to render output as follows:

Final Chrome Output

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied