IBM Integration PoT Labs Home page

IBM API Connect

API lifecycle include creating, running, managing, and securing APIs

Return to main lab page


Table of Contents


1. IBM API Connect

IBM API connect is an integrated API management offering, where all of the steps in the API lifecycle, and the actions that surround it, are performed within the offering.

alt text

2. The Steps of the API Lifecycle Include Creating, Running, Managing, and Securing APIs

2.1 Let’s Start

First make sure you are logged into the CP4I Platform Navigator using the account the instructor provided to you.

4. Click on the API Connect link to take you to the API Manager Home page.”

alt text

5. You will now be on the APIC log in page. Select the Common Services User Registry This will log you into the Provider Org you will be using.

alt text

6. Once you are on the main page make sure you are in the correct POrg. It should contain your userid.

alt text

7. When logged in and connected to the APIC Home Dashboard you will see a few tiles and a tab on the left-hand side of the page. You can use the left-hand menu or the Develop APIs and Products tile.

alt text

2.2 Import API

There are a few ways to pull existing API’s flows or manually expose an API on this page. Whether it’s starting from scratch or pulling from an asset from a connected asset repo they all achieve the same thing.

For this Lab we will use the Open API Document (salesforce-0.0.1.yaml) we downloaded from our ace integration server earlier in order to import the API.

1. For now, we will click Add and select API from the dropdown.

alt text

2. On the create page you will be greeted with choices of how you would like to add an API. And on the top you will see option for OpenAPI 2.0 or Open API 3.0. For this lab we will use the OpenAPI 2.0 Go ahead and click Import from existing API Import and click Next

alt text

3. On the Import API page either drag and drop the yaml file from the Saleforce Designer lab or click to upload it. Click Next.

alt text <!– 4. The next screen will ask if you want to activate the API. This will automatically create and expose your api however for this lab we will NOT check that box and just click Next

alt text –>

4. You will see the following summary page that shows the definition was successful generated. Click on Edit API This will take you to the designer page and will populate the fields inside APIC with what was able to be pulled from the document we imported.

alt text

3 Configure API

After importing the existing API, the first step is to configure basic security before exposing it to other developers. By creating a client key and secret security, you are able to identify the app using the services. Next, we will define the backend endpoints where the API is actually running. API Connect supports pointing to multiple backend endpoints to match your multiple build stage environments. Finally, we will configure the proxy call to invoke the endpoint.

3.1 Configure API Key security

The API Designer is a graphical user interface within the developer toolkit and provides functions for the creation and configuration of API definitions, running offline.

1. On the Design page you will notice the small red dot indicating an error. This is related to not having https in our schemes. Click on the + next to the Schemes List

In the Add object window click on the select option and select https.

Click Create and click Save to save the API changes

alt text

2. You will now be showing Schemes List(2)

In the upper Right corner where you saved the API you will see the pop-up showing the API has been updated. Go ahead and click the x to close it.

alt text

Note Whenever you do a Save the following pop-up will show up. Go ahead and click the x to close it.

alt text

3.2 Security Definition

After importing the existing API, the first step is to configure basic security before exposing it to other developers. By creating a client key and secret security, you are able to identify the app using the services. Next, we will define the backend endpoints where the API is actually running. API Connect supports pointing to multiple backend endpoints to match your multiple build stage environments. Finally, we will configure the proxy call to invoke the endpoint.

1. Moving on to Securing the API. On the left-hand side let’s click on Security Schemes.

Click on the + and we will start adding the Client ID

alt text

2. We will first create a client-id filling in the page with the following info.

alt text

3. After you select apiKey the following window will open. Finish filling it in with the rest of the info and click Create

Key type = client_id

Located In = header (from dropdown)

Varible name = x-client-id

alt text

4. Repeat steps 1 to 2 to create the Client-secret as a Type Client-Secret. It should look like the following screen:

alt text

5. You should now have a Client id and secret for your Security Schemes (2).

alt text

6. Go to the Security under Produces and click the “+” to add our security.

alt text

7. Once you have selected both click on Submit. Also go to the upper right and click on Save to save all your updates.

alt text

8. One last thing to do on the Design tab. Click on Host and then save the host name to a notepad and leave this blank. We will use this in the next section when we setup our apigw proxy. Also go to the upper right and click on Save to save all your updates.

Note - make sure that the Host is blank

alt text

3.3 Define Target-URL for Sandbox environment

1. Click on the gateway tab. This is where we will setup our Gateway and Portal setting for our API. Make sure that all your updates are saved by checking the upper right corner.

alt text

2. Now click on the target-url and use the host name that we saved from step 7 above. Make sure to add http:// in front it and save it. Once done click on the Policies in the left menu.

alt text

3. You will now see the assemble view. With assemblies, you can readily tailor your APIs to include components such as activity logging and redaction of specific fields. This view includes a palette, which lists available components, a property sheet, which is used to configure a component, and a canvas, which is used to arrange and visualize the assembly’s components.

alt text

3. Below the canvas is the details for the Invoke. Scroll down to the URL and you will see $(target-url) please type $(request.path) after it. This will append the path we created earlier to our Invoke components URL. Click Save in the upper right corner.

alt text

4. Test the API

In the API designer, you have the ability to test the API immediately after creation in the Assemble view!

1.Toggle Offline to activate API and to publish the API itself to the gateway for testing

alt text

2. You will see that the API is now online. Close the API updated pop-up in the right.

alt text

3. You will see you have both opertions available for your API. Select the one that will return the first 4 Accounts and click Send.

alt text

4. In the first time of running the API after publishing the API, the security warning dialog box may show. Please click on the here link and accept the certificate to see the 401 message.

alt text

5. In the Response section you should see the results of your API call. Review this and save one of the Account IDs to test the other operation.

alt text

6. Now select the operation to retrieve one AccountID. Replace {AccountID} with one of the accounts Ids from the first test and click Send

alt text

7. In the Response section you should see the results of your API call for just the one Account ID.

alt text

5. Publishing

Now that your API has been activated and tested to work you may want to publish it to a product that can make use of it, or if you’re just starting like us we can create a product for this API to live within.

1. There are a few ways to go about this but for this lab let’s go back to the development tab that we first saw when we attempting to create an API.

alt text

2. Once here you will see the title, version, type, and time last modified of your API. Click the three dots at the end of your API and choose Publish.

alt text

3. Since this is our first product let’s go ahead and give it a title and click next.

alt text

4. Each organization can create and manage several catalogs containing different combinations of API and products and its own developer portal. For this lab let’s stick with the sandbox catalog and click Publish.

alt text

5. We have now created a consumable product that we can find in our developer portal.

Something to note is we completely skipped the stage portion of the product. Normally you would want to stage the product make changes to visibility, subscribability, API’s, categories to include, and lastly subscription plans and rate limits. An example of what I’ve mentioned can be seen below.

alt text

5. Developer Portal

Application developers discover and use APIs by using the Developer Portal. You can customize the Developer Portal for your application developers. In addition to allowing application developers to find and use both free and paid APIs, the Developer Portal provides additional features including forums, blogs, comments, and ratings, together with an administrative interface for customizing the Developer Portal.

Now that your product is published let’s view it in the developer portal. This can be found under the Manage section of APIC.

1. Click on the Manage Tab on the left side bar.

alt text

2. Click the catalog in which you published the API (sandbox).

alt text

3. Click on Catalog setting

alt text

4. Copy and paste the Portal URL into your browser in a new tab.

alt text

5. The portal is setup for self service so we will create a new account as a developer.

Note if you have already created a Portal account in another lab then you can use that to sign into the portal.

alt text

6. Fill in the form and make sure to use a valid email address since that is where the activation email is sent. At the bottom when done click on Sign up.

alt text

7. You will receive an email that you will copy the link and paste in to your browser to complete the registration at which point you can log in.

alt text

8. Go now to the Sign in and enter your Username and password you just created.

alt text

9. Once you are logged in your can explorer varies sections in the developer portal. For now lets go the Account Product we created and Published to.

alt text

10. Now from the Products page we see our API for Salesforce Accounts and below that you see Plans. This can be configured back in the Products section where you may add plans for Silver and Gold plans. We have just the default for this one. Click Select on the Default Plan tile.

alt text

11. We will now need to Subscribe to the API to use it. You may have other applications already created from other labs. We will create a new one for this one.

alt text

12. Enter a name for this application and click Save.

alt text

13. You will get the following page. Save the Key and Secret into notepad and then click X to close window.

alt text

15. With an app now created let’s travel back to the API Products page of the developer portal (upper left) and click on the product shown that we created and published to.

alt text

16. We will also need to subscribe to a plan for this Product. Since we only have the Default plan we will use that.

alt text

17. Select the existing application.

alt text

18. Confirm subscription click next

alt text

19. Subscription completed. Click done

alt text

20. Click on the API that we will now test.

alt text

21. Here we will select the GET account operation on the and then select Try it.
The Client ID will have the App name we created earlier. You will need to copy the secret that we saved and paste it in the Client secret. Then click Send.

alt text

22. You will see the response on the bottom of the page.

alt text

23. Now click Send a few more times to run the API several times, click on Apps on the top menu and select the Active app that we are using.

alt text

24. This will give you info on the APIs that you are running.

alt text

Return to main lab page

The End.