Create REST API Using Data Integration Platform
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:
- Start an HTTP Server on any port.
- Use the Execute SQL processor to fetch the records from the database.
- Send the HTTP response in JSON format.
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.
Step 2:
Drag the ExecuteSQL processor and configure the DBCPControllerService for the processor as shown in the following image.
Give the SQL Select query with the where clause parameter that should be passed dynamically from the URL as follows:
Ensure you have the table from that you are going to query the database.
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.
Step 4:
Configure the HandleHttpResponse processor to send the response to the client from your database server.
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: