+ All Categories
Home > Documents > Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with...

Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with...

Date post: 21-May-2020
Category:
Upload: others
View: 34 times
Download: 0 times
Share this document with a friend
45
Creating an assembly REST API with IBM API Management 3.0.0.1 Creating an assembly REST API with IBM API Management 3.0.0.1 © 2014 Copyright IBM Corporation Page 1 of 45
Transcript
Page 1: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Creating an assembly REST API with

IBM API Management 3.0.0.1

© 2014 Copyright IBM Corporation Page 1 of 45

Page 2: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

TABLE OF CONTENTS

OBJECTIVE .................................................................................................................................... 3

PREREQUISITES ........................................................................................................................... 3

CASE STUDY ................................................................................................................................. 3

USER ROLES ................................................................................................................................. 4

BEFORE YOU BEGIN .................................................................................................................... 4

LOG INTO THE API MANAGER .................................................................................................... 6

CREATE A BRANCHES REST API ............................................................................................... 6

CREATE A BRANCH LOCATION ASSEMBLY RESOURCE ........................................................ 9

ADD A BRANCH ADDRESS HTTP GET OPERATION TASK .................................................... 13

ADD A GOOGLE GEOCODE API HTTP GET OPERATION TASK ............................................ 18

BUILD THE BRANCHES API RESPONSE ................................................................................. 34

ADD THE BRANCH LOCATION RESOURCE TO THE PUBLIC PLAN .................................... 39

TEST THE BRANCH LOCATION RESOURCE ........................................................................... 42

SUMMARY .................................................................................................................................... 45

© 2014 Copyright IBM Corporation Page 2 of 45

Page 3: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

NOTE: This tutorial demonstrates the Google Geocoding API, it is included only as an example. If you wish to use the Google Geocoding API then you must adhere to the rules and conditions which are placed on them by Google through their license. See the Google Geocoding API Documentation (https://developers.google.com/maps/documentation/geocoding/) for more details.

Objective In this tutorial, you will learn:

How to assemble calls to multiple REST JSON and XML services

Prerequisites

This tutorial is the second in a series, it builds on the Creating a proxy REST API with IBM API Management 3.0.0.1 tutorial. It assumes that the Public plan which was constructed as part of that tutorial is in place.

For more information about this series and other tutorials please see:

http://developer.ibm.com/apimanagement

Case studyBank A has an existing set of REST based services that they would like to expose through APIs in order to foster growth within the mobile and device market. The Bank A business team knows that an increased mobile and device application presence will enhance their brand image and increase customer satisfaction.

After considering building their own API management solution, the Bank A technology team has decided to implement an IBM API Management solution as it will allow them to enter the market quickly at a reduced cost.

In this tutorial you will document, create and implement a new resource using a combination of existing RESTful services that locate a branch and retrieve the coordinates for an address in order to calculate the Google Maps URL for a branch, as shown in the Figure below.

© 2014 Copyright IBM Corporation Page 3 of 45

Page 4: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

IBM API Management

BranchLocationService

GET /{branchId}/location

address, googleMapsLink

GET /{branchId}/locationid, name, streetAddress,

city, state, zipCode

Google Geolocation

Service

GET /xml?address=<address>&sensor=false

formatted_address, lat, lng

Figure - Branch Locator REST Assembly

User rolesIBM API Management 3 allows different roles to be assigned to users. For more details of the different user roles and descriptions of them please see the following page in the Knowledge Center:

Adding users and assigning roles

This tutorial has been written assuming that you are an Administrator or Organization Owner. If you are another role, such as Product Manager or Developer then some of the required functionality will not be available to you so you may need to contact an Administrator or Organization Owner to perform certain actions, such as:

• The ability to edit APIs is not available to Product Managers.

Before you beginIt is assumed that the Exposing a proxy REST API with IBM API Management 3.0.0.1 tutorial has been completed before starting the steps provided here. See Prerequisites section for more details.

© 2014 Copyright IBM Corporation Page 4 of 45

Page 5: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Access the Bank A Backend Service

Verify that the backend applications are available. Remember that the goal is to expose these services as a managed API on the IBM API Management platform.

1. Open a new browser tab and navigate to the URL http://banka.mybluemix.net/home/index.html

2. Click on the example URI endpoint for the Service titled Branch Location Service (JSON) to make sure that the location service is operational. This is the service that will be used as the first step of the assembly. By clicking on the link you are making a REST based GET call to return the address of a bank branch, the branchId is passed in as a path parameter, valid branch values are 101, 102, 103.

Access the Google Geocode api

One of the steps in the assembly you are going to build is going to call out to the Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/).

3. It is worth checking that the api is available by creating a new tab or window for your browser and entering the following URL in the location field:

https://maps.googleapis.com/maps/api/geocode/xml?address= 650+Harry+Road,San+Jose,CA,95120-6099&sensor=false

This will return an xml document containing the response from the Google Geocoding API.

NOTE: Keep the browser tabs open. You will need to access information from them later in the tutorial.

© 2014 Copyright IBM Corporation Page 5 of 45

Page 6: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Log into the API Manager

4. Open a new browser tab navigate to the URL https://<managementserver>/apimanager

Where <managementserver> is the IP Address or hostname of your management server.

5. Sign in to the IBM API Management platform by clicking entering your credentials and clicking Sign In.

6. After you sign in, the API Manager Home page is displayed. The home screen displays activity graphs for each environment.

7. At the top of the screen, the primary banner contains a drop down list for your organizations and your login name. You must belong to an organization to use the API Manager UI.

Create a Branches REST API

In the first tutorial in this series, Exposing a proxied REST API with IBM API Management 3.0.0.1, you created a simple REST proxy of an existing service. A proxy REST service allows you to monitor the use of the service and enforce SLAs (e.g. rate limits). While there are times when a proxy service may suffice it is often the case that you don’t have an existing API that exactly matches your requirements and you would like to expose a new API. This may be a

© 2014 Copyright IBM Corporation Page 6 of 45

Page 7: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

combination of existing services, which may also require some transformation or manipulation of the response that the existing service(s) return.

In the following example, Bank A would like to expose a new API resource which returns the address and Google Maps URL for a specific branch. For this resource the calling application will need to provide an identifier for the branch being located. Bank A also appreciates that customers would like the map URL to be provided with the address so that they do not need to do a separate search for the address in a map tool.

The resource will be implemented by combining the results of two HTTP GET calls, one that gets the branch address and one that gets the longitude and latitude for the address which allows the Google Maps URL to be calculated.

8. Click APIs in the navigation pane. This will take you to the Draft APIs listing.

© 2014 Copyright IBM Corporation Page 7 of 45

Page 8: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

9. Since this resource is not related to Loans, click the + REST button to create a new REST API.

10.Populate the fields as shown in the table below. When complete, click the Add button.

Field Name Value

API Name Branches

API Context branches/v1

API Description Operations related to Bank A branches

© 2014 Copyright IBM Corporation Page 8 of 45

Page 9: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

11.After creating the Branches API it will immediately appear in the list of available APIs.

Create a Branch Location Assembly Resource

12.Click the Branches API link to define the specific resources that are available for it.

© 2014 Copyright IBM Corporation Page 9 of 45

Page 10: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

13.Set Identify Application Using to Client ID.

14.To create a single location resource that supports a GET operation, click + Resource.

© 2014 Copyright IBM Corporation Page 10 of 45

Page 11: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

15.Remove the POST method by clicking the cross.

16.Populate the fields as shown in the table below. When complete, click the Add button.

Field Name Value

Path {branchId}/location

Display Name Location

Description Branch Address and Google Maps URL

17.Now that the Location resource has been defined, click on the Edit icon to edit the resource details.

© 2014 Copyright IBM Corporation Page 11 of 45

Page 12: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

18.Enter a description for the parameter as listed in the table below. All path parameters are required so the Required checkbox is already selected and is un-editable.

Parameter Description

branchId The unique branch ID

19.Click on the Response Body tab and paste in the sample JSON response for the resource below. Click somewhere else on the screen and the JSON will be automatically formatted for you.

{ "address": "650 Harry Road, San Jose, CA 95120, USA", "googleMapsLink" : "http://maps.google.com/?q=37.2110625,-121.8054238"}

© 2014 Copyright IBM Corporation Page 12 of 45

Page 13: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

20.For this resource you will create an assembly of two existing services. Select the Implementation tab and ensure the Assemble tab is selected.

Add a Branch Address HTTP GET Operation Task

21.Click the + icon to add a connector to the resource implementation, and select the GET Operation in the HTTP section.

© 2014 Copyright IBM Corporation Page 13 of 45

Page 14: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

22.Click on the HTTP GET OPERATION to edit the task.

23.Create a Connection using the values in the table below and click Connect. The URL you entered will be verified and focus will automatically move to the Define section of the assembly implementation.

Field Name Value

Name Branch Address Service

URL http://banka-rs.mybluemix.net/branches/v1/{branchId}/location

© 2014 Copyright IBM Corporation Page 14 of 45

Page 15: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

24.Return to the example Branch Location Service (JSON) browser tab or window. This is the service you entered the URL for in the Connection settings. By opening the example in your browser you have made a REST based GET call to the service, passing a sample branchId “101” as a path parameter in the URI.

Copy the JSON response to the clipboard (Type CTRL-A to select the JSON response and CTRL-C to copy the text)

25.Return to the API Manager browser tab or window. You will be in the DEFINE stage of the HTTP GET OPERATION task.

26.Click on the Response Body text area and paste the JSON response you just copied (Type CTRL-V to paste). Click somewhere else on the screen and the JSON will be automatically formatted for you.

27. Select Configure to map the input parameter of your API to the input parameter of the HTTP GET Operation

© 2014 Copyright IBM Corporation Page 15 of 45

Page 16: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

28.Click Select Available Value for the branchId parameter of the HTTP GET Operation.

29.Map the branchId from the API you are creating to the branchId of the HTTP GET Operation by selecting branchId

30.Confirm the branchId has been mapped correctly

© 2014 Copyright IBM Corporation Page 16 of 45

Page 17: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

31.Select Review. In the 7review section you can review the configuration as well as set specific actions if an error occurs when the HTTP GET Operation is called. For this lab you will not take any actions if an error is returned.

© 2014 Copyright IBM Corporation Page 17 of 45

Page 18: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Add a Google Geocode API HTTP GET Operation Task

32.Click the + icon to add another task to the assembly implementation, and select GET Operation from the HTTP section.

© 2014 Copyright IBM Corporation Page 18 of 45

Page 19: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

33.Click on the HTTP GET OPERATION 2 to edit the task.

© 2014 Copyright IBM Corporation Page 19 of 45

Page 20: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

34.Create a Connection using the values in the table below and click Connect.

Field Name

Value

Name Google Geocoding API

URL https://maps.googleapis.com/maps/api/geocode/xml?address= 650+Harry+Road,San+Jose,CA,95120-6099&sensor=false

35.Open your browser tab or window which you called the Google Geocoding API from in the Before You Begin section of this tutorial.

© 2014 Copyright IBM Corporation Page 20 of 45

Page 21: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

36.Note that the response is in XML format. We will use another feature of the IBM API Management assembly capability in later steps to map the XML output into the JSON response for the API resource. Typically the browser will have formatted the XML response in some way. You need to copy the raw XML. For example, Chrome automatically parses XML into a document tree, so right-click on the page and select View Page Source.

37.A new browser tab opens with the raw XML output from the service. Copy the XML response to the clipboard (Type CTRL-A to select the XML response and CTRL-C to copy the text)

38.Return to your API Manager tab. You will be in the DEFINE stage of the HTTP GET OPERATION 2 task.

© 2014 Copyright IBM Corporation Page 21 of 45

Page 22: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

39. In the Define stage of the resource implementation, click on the Response Body text area and paste the XML response you just copied (Type CTRL-V to paste).

40. Select Configure to map the input parameter of your API to the input parameter of the HTTP GET Operation

© 2014 Copyright IBM Corporation Page 22 of 45

Page 23: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

41.The sensor parameter has not been exposed externally to consumers of the API, so it will be defaulted to false for all calls. Click the default value icon next to the sensor parameter, enter the value false, and then click OK.

42.The default value icon will change to green to indicate that a default value has been set. A more complex mapping is required to concatenate the response from the branch address service into the address input parameter for the Google Geocoding API, so click Map Values to use the graphical tool to map parameters.

43.Click on the connector for the streetAddress value returned from the first HTTP GET Operation

© 2014 Copyright IBM Corporation Page 23 of 45

Page 24: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

44.Drag and click the connector for the address input parameter of this task.

45.Click the + icon in the middle of the mapping to apply a mapping function.

© 2014 Copyright IBM Corporation Page 24 of 45

Page 25: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

46. In this case we require two functions to get an address in the format: “650+Harry+Road,San+Jose,CA,95120-6099”. First we need to use concatenate to combine multiple address fields together and then we need to use replace to escape spaces with the “+” character. To apply multiple functions, select Composite from the list of mapping functions.

© 2014 Copyright IBM Corporation Page 25 of 45

Page 26: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

47.Drag and drop the city, state and zipCode fields to the connector on the left side of the Composite function to add them as input parameters, and then click the edit icon to edit the function. Note that the mappings are red to indicate that the function configuration is not complete.

48.Click the edit icon on the Composite function.

© 2014 Copyright IBM Corporation Page 26 of 45

Page 27: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

49.The input parameters will be listed in the Source Fields box in the function configuration. In the Edit Composites box, click the + icon to add a new composite function.

© 2014 Copyright IBM Corporation Page 27 of 45

Page 28: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

50.Click the Copy function that has been added to change it to another function, and select Concatenate under the String functions.

© 2014 Copyright IBM Corporation Page 28 of 45

Page 29: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

51. In the Edit Parameters box for the Concatenate function, enter “,” (comma) as the default delimiter.

© 2014 Copyright IBM Corporation Page 29 of 45

Page 30: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

52. In the Edit Composites box, click the + icon to add another new composite function, and this time change Copy to Replace under the String functions.

© 2014 Copyright IBM Corporation Page 30 of 45

Page 31: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

53. In the Edit Parameters box for the Replace function, enter “ ” (space) as the original string and “+” (plus) as the new string. Click Apply.

© 2014 Copyright IBM Corporation Page 31 of 45

Page 32: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

54.The Composite function configuration is now complete and the mappings have changed to green.

© 2014 Copyright IBM Corporation Page 32 of 45

Page 33: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

55.Select Review and note that the latitude and longitude for the address are returned in the location element of the response from the Google Geocoding API. There is also a field that returns the complete address that can be used in the API response.

© 2014 Copyright IBM Corporation Page 33 of 45

Page 34: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Build the Branches API Response

56.Select Response to map the required fields from the Google Geocoding API response to the response of the resource you are building for your Branches API.

57.Select Map Values because another concatenate function will be required to build the Google Maps URL from the latitude and longitude.

© 2014 Copyright IBM Corporation Page 34 of 45

Page 35: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

58.Click on the connector for the formatted_address output field from HTTP GET Operation 2 and map it to the address field in the response. You will probably have to scroll down the Available values list to see the HTTP GET Operation 2 response.

Note that even though the output of the Google Geocoding API in HTTP GET Operation 2 is in XML format and the API response is in JSON format, the mapping tool can still be used in the same method and the data format conversion is done automatically.

© 2014 Copyright IBM Corporation Page 35 of 45

Page 36: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

59.Create a googleMapsLink in the format “http://maps.google.com/?q=37.2110625,-121.8054238” using the following steps:

a) Map the lat output field from HTTP GET Operation 2 to the googleMapsLink field in the response

b) Add a Concatenate function to the mapping

c) Map the lng output field from HTTP GET Operation 2 to the Concatenate function

d) Edit the Concatenate function and set prefix = “http://maps.google.com/?q=” and default delimiter = “,” (comma)

© 2014 Copyright IBM Corporation Page 36 of 45

Page 37: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

e) Click Apply and confirm your mapping is updated to reflect the diagram below.

f) Confirm that the Concatenate mapping is yellow due to a type casting warning by clicking the warning icon on the Response.

© 2014 Copyright IBM Corporation Page 37 of 45

Page 38: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

g) Confirm that the address mapping is only grey because it is in the background, and select it to check that it is still green.

60.The resource implementation is now complete. Click Save API at the top of the editor.

© 2014 Copyright IBM Corporation Page 38 of 45

Page 39: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Add the Branch Location Resource to the Public Plan

In order to be able to test the resource from the integrated test tool you need to first add it to a plan. In the previous tutorial you created a plan, named Public. It is this plan that you will use to test the Branch Location resource.

61.Select Plans from the navigation pane.

© 2014 Copyright IBM Corporation Page 39 of 45

Page 40: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

62.Click on the Public Plan name to open the plan editor.

63.Click + Resource.

© 2014 Copyright IBM Corporation Page 40 of 45

Page 41: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

64.Select Branches from the list of APIs in the left hand column, then select the Location resource. Click Add.

65.You will now have two resources in your Public plan. Click Save.

© 2014 Copyright IBM Corporation Page 41 of 45

Page 42: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

Test the Branch Location Resource

The integrated test tool provides the ability to test a resource from the API Manager UI, it is found within the resource editor in an API.

66.Click APIs in the navigation pane. This will take you to the Draft APIs listing.

© 2014 Copyright IBM Corporation Page 42 of 45

Page 43: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

67.Click on the Branches API name to open the API editor.

68.Click the edit icon for the Location resource.

© 2014 Copyright IBM Corporation Page 43 of 45

Page 44: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

69.Click the Test tab.

70.The Test fields should automatically be correctly populated because there is only one Environment and Plan in this organization. If you have created additional Environments and Plans since that tutorial then please ensure Sandbox and Public (Version 1) are selected.

Enter the parameter value in the table below and click the Invoke button.

Parameter Value

branchId 101

© 2014 Copyright IBM Corporation Page 44 of 45

Page 45: Creating an assembly REST API with IBM API Management 3.0.0 · Creating an assembly REST API with IBM API Management 3.0.0.1 NOTE: This tutorial demonstrates the Google Geocoding

Creating an assembly REST API with IBM API Management 3.0.0.1

71.Confirm that the correct response was returned and a 200 OK response code.

72.You can also try testing the API using the following branchId values: 102 and 103. Click Parameters to change the input parameter value before clicking Invoke again.

Summary

In this tutorial, you have built on top of the previous tutorial in this series and have learnt:

How to assemble calls to multiple REST JSON and XML services

This is the second in a series of tutorials which will cover the features of API Management 3.0. For more information about this series and other tutorials please see:

http://developer.ibm.com/apimanagement

End of Tutorial

© 2014 Copyright IBM Corporation Page 45 of 45


Recommended