When it comes to quick API development, you need both the integration experts as well as application developers to easily develop and deploy the APIs. Here is how to create a simple API with Fuse Online.
Red Hat Fuse integration solution empowers integration experts, application developers, and business users to engage in enterprise-wide collaboration and high-productivity self-service.
Navigate to OpenShift.
Click on your Tools Project.
Click on your Fuse Online Route and Log In.
The first time that you hit the Fuse Online URL, you will be presented with an Authorize Access page. Click the Allow selected permissions button to accept the defaults.
Click on Connections > Create Connection
Select Database
Enter below values for Database Configuration
Connection URL: jdbc:postgresql://postgresql.international.svc:5432/sampledb
Username : dbuser
Password : password
Schema : <blank>
Remember to replace the OCPPROJECT with the OpenShift project(NameSpace) you used in last lab. It should be your username
Click Validate and verify if the connection is successful. Click Next to proceed.
Add Connection details:
Verify that the Location Database is successfully created.
Description goes here
Click on Integrations > Create Integration
Choose Webhook
Click on Incoming webhook
It navigates to the Webhook Token screen. Click Next
Define the Output Data Type.
Click Done
{
"id": 1,
"name": "Kamarhati",
"type": "Regional Branch",
"status": "1",
"location": {
"lat": "-28.32555",
"lng": "-5.91531"
}
}
Click on LocationDB from the catalog and then select Invoke SQL
Enter the SQL statement and click Done.
INSERT INTO locations (id,name,lat,lng,location_type,status) VALUES (:#id,:#name,:#lat,:#lng,:#location_type,:#status )
Click on Add step and select Data mapper
Drag and drop the matching Source Data types to all their corresponding Targets as per the following screenshot. When finished, click Done.
Click Publish on the next screen
Add Integration Name: addLocation.
Again Click Publish.
Congratulations. You successfully published the integration. (Wait for few minutes to for the integration to be built and published)
We will use an online cURL tool to create the 101st record field in database. If you'd prefer to use the Terminal in your Che instance, go ahead and skip the online cURL instructions and just use the cURL command in your Che Terminal.
Copy the External URL per the below screenshot
Open a browser window and navigate to: https://onlinecurl.com/
Below are the values for the request.
The page will load the 204 response information from the service which means the request was successfully fulfilled.
If you are using an Environment with self signed certificates and get an SSL error, you can also use the curl utility in the terminal of your Eclipse Che environment instead of online curl.
Please make sure to use the your URL you copied and pasted
curl -k \
--header "Content-Type: application/json" \
--request POST \
--data '{"id": 101, "name": "Kamarhati", "type": "Regional Branch", "status": "1", "location": { "lat": "-28.32555", "lng": "-5.91531" }}' \
https://i-addlocation-tools1.apps.ocp-ai.redhatgov.io/webhook/KcZ3E86SUJTqIUsA8iB7Yb5Sa1KLp9cchnRO5twYnr6UTruYd1
Click on Activity > Refresh and verify if the newly record is created.
(Optional) Visit the application URL in the browser from the Location Service created in the previous lab and verify if the record can be fetched.
RESPONSE
{
"id" : 101,
"name" : "Kamarhati",
"type" : "Regional Branch",
"status" : "1",
"location" : {
"lat" : "-28.32555",
"lng" : "-5.91531"
}
}
In this lab you discovered how to create an adhoc API service using Fuse Online.