Home > Blogs > VMware vCenter Orchestrator Blog


Browsing the Netflix catalog using the vCO HTTP-REST plug-in

Here is another example how to use the new vCO HTTP-REST plug-in. Let's  browse the Netflix movie catalog using vCO. We will implement a workflow that retrieves all available titles given a simple query.

First thing we need to do is define our Netflix REST host.

NetflixRegister

Then we define operation for searching the catalog:

CteateOperation

Netflix REST  API is documented here. The REST operation made accepts a single URL parameter called term. It can be any string. The created REST host and the operation could be seen in the vCO inventory:

Inventory

Let's test the operation using the generic Invoke a REST operation workflow.

Invoke

The successful execution of the workflow looks like this:

InokationResult

It looks like there are many titles found for "Transformers".

Let's generate a workflow from this operation using Generate a new workflow from a REST operation.

Generate

We need to specify the operation, give a name for the new workflow and specify the destination folder for the generation result. Let's customize the new workflow to only return the titles.

CustomizeWorkflow

We edit the first scripting activity in the workflow by adding the following few lines:

var doc = new XML(contentAsString);

var titles = doc..catalog_title..title.@regular;

for (i in titles) {

    System.log(titles[i]);

}

 

This JavaScript code parses the xml response from Netflix. JavaScript has native support for xml which makes it very easy to extract information from xml documents. This feature is called E4X (ECMAscript for XML). Here is the result from execution of the customized workflow:

New_workflow_Execution

Consuming RESTful web services is very easy with the vCO HTTP-REST plug-in. With a few easy steps you are able to create a customized building block in the form of a workflow. Using ECMAscript for XML for handling XML you can easily manipulate the response. 

One thought on “Browsing the Netflix catalog using the vCO HTTP-REST plug-in

  1. sampath

    This is awesome !I tried it and failed to convert xml response to list.I am glad I visited this site.Now I know how to do it. very helpful. Thank you very much.

Comments are closed.