Home > Blogs > VMware vCenter Orchestrator Blog > Monthly Archives: July 2011

Monthly Archives: July 2011

vCloud Director, Twitter, Yahoo, and Foursquare.com HTTP-REST plug-in use case examples

Here are a few more use case examples showing how the vCO HTTP-REST plug-in can interact with some popular APIs.

vCloud Director

You must run two workflows to configure a vCloud Director host.

First, you must register a vCloud Director host.


Then, you must run the “Set vCloud Director authentication to a REST host” workflow from the “HTTP-REST Samples” workflow category to set the correct authentication type.


This example uses “Per User Session” session mode. To use this type of session mode, each user must be registered in both the Orchestrator LDAP and vCloud Director. The login URL must be an absolute URL. You can consult the “vCloud API Programming Guide” for details about available resources. The authentication and login to the vCloud Director instance is handled automatically by the REST plug-in so you do not need to login manually. If the session expires, it is renewed by the REST plug-in. You can receive a “403 Forbidden” error when invoking requests, if the provided credentials are invalid.

You can also use “Shared Session” to create only one connection to the vCloud Director instance. You should provide the credentials of a user who is a vCloud Director administrator.

Next, you can create an operation to add an organization to vCloud Director.


After you add the operation, you can call it by running the “Invoke a REST operation” workflow.



Twitter has a very well documented REST API at http://dev.twitter.com/doc. Twitter uses the OAuth 1.0 protocol for authentication. Once you have registered an application with Twitter, you can use the access token and access token secret to configure a REST host by using the “Add a REST host” workflow.


Consumer key and consumer secret are mandatory fields. You should provide an access token and access token secret to access a specific Twitter profile.

You can access only one Twitter account from a REST host. You can create a Twitter host for every account you need to process by using the “Clone a REST host” workflow.

Next, you need to create REST operations. The most used actions are “update status” and “get home timeline”.

Create the "get home timeline" operation.


This operation is documented at http://dev.twitter.com/doc/get/statuses/home_timeline.

After you add the operation, you can call it by running the “Invoke a REST operation” workflow.


Create the "update status" operation.


This operation is documented at http://dev.twitter.com/doc/post/statuses/update.

After you add the operation, you can call it by running the “Invoke a REST operation” workflow.


Optionally, you can create workflows from the operations. In the examples above, the {format} parameter is not required and can be set to xml or json in the operation definition.


 Yahoo uses a very simple authentication scheme for most of its APIs. When you register with http://developer.yahoo.com/, you are given a unique appid that you must pass as a request parameter to all the API calls. The example describes how to access the Yahoo Answers API. The documentation for this service is available at http://developer.yahoo.com/answers/.

The authentication must be set to “NONE”.

Create an operation to search for answers.


You have to replace the XXXXX with your own appKey that you received upon registration. You can further refine the search by adding other parameters as query parameters. The available parameters are documented at http://developer.yahoo.com/answers/V1/questionSearch.html.

After you add the operation, you can call it by running the “Invoke a REST operation” workflow.



Foursquare uses OAuth 2.0 for authentication. It is a simpler protocol than OAuth 1.0: it only requires a token that is passed as a query parameter, however using https is mandatory.
The foursquare server is located at https://api.foursquare.com/v2/. You must first add a host. The authentication must be set to OAuth 2.0 and you must provide a token.


Create an operation to retrieve the user’s profile.


The operation URL is users/self. The list of all available operations is described at https://developer.foursquare.com/docs/explore.html#req=users/self. If you are logged-in to your foursquare account, accessing this page also generates a token for use.

The request token is added as a query parameter by the plug-in, so the user doesn’t have to handle the low level authentication details.

After you add the operation, you can call it by running the “Invoke a REST operation” workflow. 


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.


Then we define operation for searching the catalog:


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:


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


The successful execution of the workflow looks like this:


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.


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.


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) {




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:


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.