Skip to content

Deploy Your First Integration as API

Overview

In this guide, you will:

  • Create a simple Integration as an API that acts as a service which calls a third party endpoint and returns its response to the client.
  • The endpoint responds with a JSON with a key message and the value Hello World!!!, and the service deployed in Devant forwards this response to the client.
  • Use WSO2 Micro Integrator (MI) to develop the API.
  • Push the integration to Devant, which automatically builds and deploys the integration to the development environment.
  • Test the integration.

Prerequisites

  1. GitHub account: Create a GitHub account if you don't have one already.
  2. If you're signing in to the Devant for the first time, create an organization:
    1. Go to https://console.devant.dev/ and sign in using your preferred sign-in option.
    2. Enter a unique organization name. For example, Stark Industries.
    3. Read and accept the privacy policy and terms of use and Click Create.
    4. Select your region and click Confirm.
  3. VS Code: Install VS Code if you don't have it installed already.

Step 1: Attach a Git repository

  1. Go to https://console.devant.dev/new and sign in. This opens the new integration page.
  2. On the new integration page, click Attach a Git Repository.

    Tip

    If you're using a public Git repository, you can skip ahead to sub-step 8. Click Use a Third-Party Public Git Repository and enter the repository URL.

  3. Click Authorize with GitHub to connect Devant to your GitHub account. If you haven't connected your GitHub repository to Devant, authorize the WSO2 cloud app with your GitHub account WSO2 Cloud App.

  4. Under the Organization dropdown click + Add. This redirects you to the Install WSO2 Cloud App page.
  5. Select your GitHub account and install WSO2 Cloud App

    Note

    The WSO2 Cloud App requires:

    • Read and write access to code and pull requests.
    • Read access to issues and metadata.

    You can revoke access at any time. Write access is used to push changes directly to your repository.

  6. Under the Organization dropdown, select your organization. If it is still not listed, click the Refetch button.

  7. Select a repository to save your integration.
  8. Select a Branch and a Path of the selected repository to save your integration.
  9. Name and Identifier fields are automatically populated. Additionally, you can edit them to your preference.
  10. Select the Technology as Micro Integrator.
  11. Choose the Integration Type as Integration as API and Click Create.

This redirects you to the overview page of the integration. Now, let's design the integration.

Step 2: Install the MI extension

  1. Click Install Micro Integrator extension on the overview page. This opens the VS Code extensions page.
  2. Click Install to install the extension. This installs the development environment for MI on VS Code.

Step 3: Develop API in VS Code

  1. Go to the Overview page of the integration you have created and click Develop in Micro Integrator. This will clone your project and open it in Micro Integrator.

Note

You need the following to work with the MI for VS Code extension.

  • Java Development Kit (JDK) version 21
  • WSO2 Micro Integrator (MI) 4.4.0 runtime

If you don't have them installed on your local machine, the MI for VS Code extension automatically prompts you to download and configure them during the project creation step:

  1. Click Download Java & MI to download and set up Java and MI runtime.

    Download Java and MI

    Info

    If your local machine has a different JDK or WSO2 MI version installed, the system will prompt you to download the required versions.

    1. Click Download to install the required JDK or/and MI version(s).
    2. Once the download is complete, configure the Java Home or/and MI Home paths by clicking Select Java Home or/and Select MI Path, respectively.

    If the required JDK and WSO2 MI versions are already installed, you can directly configure the Java Home and MI Home paths in this step by clicking Select Java Home and Select MI Path, respectively.

    Once the process is complete, a window reload is required, and you will be prompted with the following message:

    Reload Window

  2. Click Reload Window.

2. The Micro Integrator extension will automatically direct you to the Create API page.

3. Enter HelloWorldAPI as the API Name. The system automatically populates the API Context field with the same value.

Create New API

4. Click Create.

Once you create the API, a default resource is automatically generated. You can see this default resource listed in the Service Designer under Available resources. You'll use this resource in this tutorial.

Step 4: Design the integration

Now, it's time to design your API. This underlying logic is executed behind the scenes when an API request is made. In this scenario, you first need to call the endpoint. For that, you have to add an HTTP connection. Follow the below steps to create an HTTPS connection.

  1. Open the Resource View of the API resource by clicking the GET resource under Available resources on Service Designer.

    Add new connection

  2. Once you open the Resource View, click on the + icon on the canvas to open the palette.

    Add new connection

  3. Under Mediators > HTTP select the GET operation.

    Add new connection

  4. In the Add Get pane that appears, click Add new connection.

    Add new connection

  5. Under Add New Connection, select HTTPS.

  6. Specify the following values:

    Property Value
    Connection Name HelloWorldConn
    Base URL https://apis.wso2.com
  7. Click Add. You'll be directed to the Add Get pane again.

  8. Enter /zvdz/mi-qsg/v1.0 as the Relative Path. So the actual endpoint is https://apis.wso2.com/zvdz/mi-qsg/v1.0.

    Add new connection

  9. Click Submit.

    Now, let's add a Respond Mediator to respond the message to the client.

  10. Click on the + icon placed just after the HTTPS GET operation to open the palette.

  11. Select Respond mediator under Mediators and click Add.

Now you have successfully designed the integration.

Note

You can view the source view by clicking on the Show Source (</>) icon located in the top right corner of the VS Code.

Step 5: Run the integration artifacts

Now that you have developed an integration using the MI for the Visual Studio Code plugin, it's time to deploy the integration to the MI server runtime.

Click the Build and Run icon located in the top right corner of VS Code.

Build and run

Step 6: Test the integration service locally

Now, let's test the integration service. For that, you can use the inbuilt try-it functionality in the MI for the VS Code extension. When you run the integration artifact as in Step 4, the Runtime Services interface opens. You can see all the available services.

Select HelloWorldAPI, which you have developed, and test the resource.

Test API

Note

For more information, refer to Micro Integrator Documentation.

Step 7: Push to Devant

  1. Click Source Control icon on the sidebar.
  2. Click + to stage all the changes.
  3. Add an appropriate commit message and commit.
  4. Click Sync Changes to push the changes to remote.

Step 8: Test the API

  1. After you push, Devant detects the commit, builds it, and deploys the integration to the development environment, showing the status on the overview page.

    Note

    The build process may take some time. Once complete, the build status changes to Success. You can see the Build History by clicking Build in the left navigation.

  2. Once the Build Status shows as Build completed, click Test on the development environment card. This will bring you to the Console page.

  3. Click Get Test Key to get a key for testing.
  4. You will have a single resource available GET /. Click to expand the resource.
  5. Click Try it out.
  6. Click Execute. You will see the response from the backend service as {"message": "Hello World!!!"}.

    Test API Response