Build an Integration as API
/hello/greeting, calls an external API, and returns the response to the caller.An HTTP service exposes your integration logic as a REST endpoint. This quick start shows the full cycle: create a service, add a resource, connect to an external API, and test it using the Try-It/Test panel in WSO2 Integrator.
Prerequisites
A working WSO2 Integrator environment.
Step 1: Create the integration
-
On the project home page, click Create on Cloud.

-
The WSO2 Integrator cloud editor opens in your browser.

The cloud editor creates a default integration for you, so you don't need to name it now. You can change its name when you deploy it. For more information, see Save and deploy.
Step 2: Add an HTTP service
-
In the design view, click Add Artifact manually.

-
Select HTTP Service under Integration as API.

-
Keep Service Contract as Design From Scratch.
-
Set Service Base Path to
/hello. -
Click Create.

Step 3: Add a resource
-
In the HTTP service design view, click + Add Resource.
-
Select GET.

-
Set Resource path to
greeting. -
Click Save.

Step 4: Connect to an external API
-
Click + inside the resource flow.

-
Click Add Connection under Connections.

-
Select HTTP under Pre-built Connectors.

-
The Connect to Third-Party service form opens. Set Url to:
https://apis.wso2.com/zvdz/mi-qsg/v1.0
-
Scroll to the bottom of the form. Set Connection Name to
externalApi. -
Click Save Connection.

Step 5: Call the external API
-
Click + inside the resource flow.

-
Select externalApi.
-
Select Get.

-
Set Path to
/. -
Set Result to
response. -
Set Target Type to
json. -
Click Save.

Step 6: Return the response
-
Click + inside the resource flow, below the external API call node you just added.

-
Select Return under Control.

-
In the Expression field, select
responsefrom the variables. -
Click Save.

Step 7: Run and test
-
Click Run.
-
Click Test in the confirmation dialog.
-
Click Execute.
-
Confirm the response shows
200 OKwith aHello Worldbody.
Step 8: Deploy to WSO2 Cloud
To deploy your integration to WSO2 Cloud from the cloud editor, see Save and deploy.
Source code
View the generated Ballerina code
The steps above generate the following complete, runnable Ballerina program:
import ballerina/http;
listener http:Listener httpDefaultListener = http:getDefaultListener();
final http:Client externalApi = check new ("https://apis.wso2.com/zvdz/mi-qsg/v1.0");
service /hello on httpDefaultListener {
resource function get greeting() returns json|error {
do {
json response = check externalApi->get("/");
return response;
} on fail error err {
// handle error
return error("unhandled error", err);
}
}
}