Develop Integration as API¶
Overview¶
In this guide, you will create a simple integration as an API that acts as a service that calls a third-party endpoint and returns its response to the client.
Prerequisites¶
Before you begin, make sure you have the following:
- Visual Studio Code: Install Visual Studio Code if you don't have it already.
- WSO2 Integrator: BI Extension: Install the WSO2 Integrator: BI extension. Refer to Install WSO2 Integrator: BI for detailed instructions.
Step 1: Create a new integration project¶
- Click on the BI icon on the sidebar.
- Click on the Create New Integration button.
- Enter the Integration Name as
HelloWorld. - Select the project directory by clicking on the Select Path button.
-
Click on the Create Integration button to create the integration project.
Step 2: Create an integration service¶
Generate with AI
The integration service can also be generated using the AI-assistant. Click on the Generate with AI button and enter the following prompt, then press Add to Integration to generate the integration service.
Create an http service that has base path as /hello, and 9090 as the port. Add GET resource on /greeting that invokes https://apis.wso2.com/zvdz/mi-qsg/v1.0 endpoint and forward the response to the caller.
- In the design view, click on the Add Artifact button.
- Select HTTP Service under the Integration as API category.
- Select the Design From Scratch option as the Service Contract.
- Specify the Service base path as
/hello. -
Click on the Save button to create the new service with the specified configurations.
Step 3: Design the integration¶
- Click on Add Resource button and select GET HTTP method.
-
Change the resource path to
greetingand click the Save button. -
Click the â button to add a new action to the resource.
- Select Add Connection from the node panel.
- Search for
HTTPin the search bar and select HTTP as the connection type. - Add the URL
"https://apis.wso2.com"to the connection URL field. - Change the Connection Name to
externalEpand click Save. - Select Connections -> externalEp -> get from the node panel.
Set
/zvdz/mi-qsg/v1.0as Path,epResultas Result, andstringas Target Type. -
Fill in the request details as below and click Save.
-
Click â button again and select Return from the node panel.
-
Select the
epResponsevariable as the Expression from the dropdown and click Save. This step will return the response from theHelloWorldAPI endpoint.
Step 4: Run the integration¶
- Click on the Try It button in the top right corner to run the integration.
- If the integration is not running, there will be notification messaging asking to run the integration.
- Click Run Integration if a notification is appeared.
- Once the integration is started, Try-it will open up on the right side.
-
Click on the Run button to invoke the
greetingresource. -
Additionally, you can test the integration using REST clients like Postman or curl.
curl http://localhost:9090/hello/greeting {"message":"Hello World!!!"}% -
Click on the âšī¸ button or press
Shift + F5shortcut to stop the integration.







