Friday, July 17, 2015

Connecting to a Public REST API in CIS

Lets see how to connect to a Public REST API in CIS.

The REST API I have selected is the Google Maps API.
input_address is the input you give to the URL at run time. For Eg: Any valid address like (San Diego)

This URL has two parts the BASE URL and the OPERATION URL

From the Google Maps URL:
OPERATION URL: /maps/api/geocode/xml?address={input_address}

1.  Login into CIS and click on a folder where you have write access and select New Data Source:

2. It will bring a pop-up where you can select the Data Source Adapter:
Select REST as your Data Source Adapter:

3. Click on Next at the bottom of the screen and you can enter the connection information as below.

Name: Any Valid Name. I have named mine as GOOGLE_REST_API.
Base URL:
No Need to enter any Login/Password as anyone can access these Public REST API's .

4. Now in the Operations Tab Click on the + Symbol to add a new operation.

5. A window will pop-up where you enter any name for your operation. Give it any name.

6. Now enter the Operation URL in the Operation URL Text Box:
Our Operation URL: /maps/api/geocode/xml?address={input_address} and Hit Parse.
When you hit Parse it will Parse the Operation URL and detect the input parameters in the URL.

7. Hit Create and Close in the Bottom End of the Window and it will Introspect the Operation by combining the Base URL and The Operation URL.

Click on the Operation Name and Click Next

8. Hit Finish and It will introspect and give you the Introspection Task Status Report. Make sure the operation is added in the report as shown below.

9. Click OK and you can see your operation in the resource directory. Open the operation and click on Execute.

10. You have to enter a valid input_address so the Google Maps API can give you the appropriate information like Country Information, Latitude, Longitude Information etc. The Information is in XML so you can use this XML in SQL Scripts, Views and publish them for the consuming applications.

Note: If you would like to convert XML to tabular format you will have to use the XSLT Transformations provided by CIS.


gangadhar said...

do i need to parse the json manually ? i could see some concepts like ==> Definition Set where we can define XSD with reference data. then we can get data in a tabular manner.

do you have idea on this ?

am working on composite 6.2.6

Raju said...

Hi gangadhar,

you can refer this cisco technote:
"". However this method converts the JSON to XML and then you need to convert the XML to tabular using the XSLT transformations. Hence there is a performance issue if you take this approach. If you would like to do it manually see the JSON_TABLE CIS function ( which is more robust and an easier way to convert JSON to tabular.


gangadhar said...

thanks for the reply.,

I had this issue because of my JSON response => {[{},{},{}]}, for this

1. I have changed the response to => {"results":[{},{},{}]} , not sure this what is the solution.
2. added some name to ==> "wrapper of JSON Bare respose in Source".

then i am able get the XML response and transform into Tabular data using streaming Transformer.

Gangadhar M

Raju said...

Hi Gangadhar,

Yes you are right, if the incoming JSON is not wrapped in a Top Element then you will have to use CIS to wrap the Top Element in the JSON so the XML generated by CIS is valid.