IBM Integration PoT Labs Home page

IBM API Connect v12

Create, Secure, Publish, Subscribe, and Test API

Return to main APIC lab page


Table of Contents


1. Introduction

In this lab, you will get a chance to use the IBM API Connect (APIC) Studio and its intuitive interface to import and edit an API using the OpenAPI definition (YAML) of an existing Customer Database RESTful web service.

In this tutorial, you will explore the following key capabilities:


alt text

What is IBM DataPower Nano Gateway?
IBM DataPower Nano Gateway is a lightweight, containerized API gateway built on the IBM DataPower technology foundation.

What It Is: A minimal-footprint API gateway designed for edge deployments, microservices environments, and resource-constrained infrastructure — as opposed to the full IBM DataPower Gateway which runs on dedicated hardware or full VMs.

alt text alt text alt text alt text


2. IBM App Connect - Deploying the backend REST Service

First, you will deploy a Customer Database REST service and then you will download the OpenAPI file for the Customer Database REST service that you deployed.

  1. In a browser, enter the URL for the Platform Navigator URL that is provided by your instructor.

  2. Filter instances by the student(number). You will see your instances.(br)

  3. Navigate to the App Connect Dashboard. alt text

  4. Click on the Dashboard icon in the left navigation. alt text

  5. For this lab, we already have the REST service built and available as a bar file. You can download the CustomerDatabaseV3.bar file for the service **here**.

  6. Click on Deploy integrations. alt text

  7. Click Quick start integration and click Next. alt text

  8. Drag and drop the BAR file that you just downloaded or click to upload. Once you have dragged and dropped or uploaded, you will see the bar file listed under to be imported. Click Next. alt text

  9. Click Next. alt text

  10. Give the Integration Server a Name (e.g., student(n)-customerdb) and click Create. Replace (n) with your student number, for example student1-customerdb.
    alt text

  11. This will take you back to the Runtimes Dashboard where you will see your new server. It will likely be showing Pending while it is starting up the pod.

    Note: It may take a several minutes to start up. You can refresh the page. Once it is up and running it will show the following:

    Click on the newly created Runtime. alt text

  12. Confirm that the Overview tab is selected and click Download OpenAPI Document As JSON (or) Download OpenAPI Document As YAML. Either format can be used to import in API Connect.
    alt text



3. IBM Api Connect - Import backend REST API

You will be importing the backend REST API definition into IBM API Connect Studio, then you will configure the API to enable Security, CORS, and finally publish the API to community.

  1. Navigate to the API Connect instance.

    From the IBM Cloud Pak for Integration Platform Navigator, navigate to apim-demo an IBM API Connect capability.

    Click on apim-demo instance.
    alt text

  2. If this is your first time logging in, the login page is presented. Click Cloud Pak User Registry. alt text

  3. Confirm that you are in the provider organization for your username (upper right). alt text

  4. We are now able to begin to create APIs and Products. Click API Studio alt text

3a. Create project

  1. Click Create New Project. alt text

    Name it customer-database-ngw, where ngw stands for the Nano Gateway.
    alt text

  2.  Open the project customer-database-ngw. alt text

3b. Add API

  1. Click “Add API” alt text

  2. Click “Import”. alt text

  3. Click on “drag and drop” alt text

  4. Select Customer_Database-1.0.0.yaml
    alt text

  5. Click <Create>.
    alt text

    Your backend REST API has been imported successfully.

3c. Rename the API

alt text

Change the name to customer-database-ngw, then click \<Update\>. <br>
![alt text](/CP4I-PoT-Public/APIC-labs-v12/Create-Secure-Publish-DPNGW/images/image-43a.png)

3d. Configure API - Add Gateway Policy

  1. Click (+) sign next to “Policy Sequence”.
    alt text

  2. Select “DataPower Nano Gateway”, and name the policy as “customer-database-agw-policy”, then select the API using the drop-down.
    Click <Add>. alt text

  3. Click on “Invoke” policy.
    alt text

    Wrap the endpoint URL with single quotes, then append & $relativeUrl(‘request’) after the single quote (including &).
    alt text
    alt text

  4. Change URL Type to be Jsonata alt text

3e. Configure CORS

  1. Click on the API Customer_Database under APIs section (left), then scroll down and click on CORS (Cross-Origin Resource Sharing).

  2. Click <\Add>.
    alt text

  3. Enter name, namespace (project), then click <\Add>.
    alt text

  4. Edit CORS.
    alt text

    SCROLL down, and uncheck “Expose headers”, then Save.
    alt text

3f. Configure Security

  1. Click the Components section Scroll down to “Components” section, then on the right side again scroll down to “Security Schemas” section.

  2. Click <\Add Security Schema>.
    alt text

  3. Add “X-IBM-Client-Id”.
    alt text

  4. Similarly, add “X-IBM-Client-Secret”.
    alt text

  5. Now, click “Security” section and then click on <\Add Security Schema>.
    alt text

    First, select both apikeys, then click on <Create AND group (2 selected)> button.
    alt text

    Now, click <\Add>.
    alt text

    alt text


4. Publish API

Here, you will publish the API to IBM DataPower Nano Gateway and Developer Portal community for consuming the API.

  1. Click on “Publish” alt text

    alt text

    alt text

  2. Click on Catalog button. Don’t worry if that little window disappears quickly, you should be able to access the Catalog through Manage section in the left.
    alt text

  3. Navigate to the Portal Section under Catalog Settings, then click on the Portal URL.
    alt text


5. API Connect Developer Portal

  1. Welcome to developer portal alt text

  2. Click on <Sign up> button.
    alt text alt text

  3. Login as student(n) now.
    alt text

  4. THis is the Developer Portal Welcome page.
    alt text

  5. Click on “API Products”.
    alt text

  6. You should see customer-database-ngw API that was published earlier, then Click on the API.
    alt text

5a. Subscribe API

  1. Subscribe the API, Click <Subscribe> alt text

  2. Click “Create new subscription”, then click <Request>.
    alt text

  3. Enter demo-app-2, then click <Save> alt text

  4. Click <Save>
    alt text

    See demo-app-2 alt text

  5. Click on the demo-app-2. You should see that your subscription is successful, and acknowledged by the DataPower Nano Gateway.

    You should also see ClientID, and ClientSecret being generated.
    alt text

    SAVE the ClientID, and ClientSecret to a NOTEPAD or TEXTPAD. You will need them when testing the API.



6. Test the API

  1. Click on “API Products”. alt text

  2. Click on the API Product customer-database-ngw-product, then click on the API. alt text

  3. Expand “API Resources”. alt text

  4. Navigate to GET under /customers operation, then click on <Try>.
    alt text

  5. Click Headers tab to populate our ClientId, and Secret.
    alt text

  6. The ClientID should be populated automatically, you need to populate X-IBM-Client-Secret and its value that saved into the Notepad.
    Click <Add New>, and add X-IBM-Client-Secret.
    alt text

  7. Click <\Send>.
    alt text

  8. If successful, you should get “200 OK” Result. alt text

  9. A DataPower Nano Gateway Runtime pod should be started. Switch to OpenShift Console, workloads -> pods -> under project cp4i-apic.

    You should see a pod like this.
    alt text



6.Summary

Congratulations, you have completed the Create, Secure, publish, subscribe, and tested your API. Throughout the lab, you learned how to:

Return to main APIC lab page