Requesting the VRA Developer Friendly Blueprint with curl

In my last post I showed you how to create the developer friendly blueprint in vRealize 7. In this guide we will show how to invoke the REST API to make this request. Before we get into the details it helps to illustrate how each team wants to interact with the infrastructure. Many vSPhere admins, including myself, spend most of their time in some sort User interface. The developer on the other hand is usually living in command line or some sort of IDE environment writing code. For repetitive tasks such as server build they would rather code and script it once rather than going into a GUI to point and click. Developer also want a way to programmatically integrate their other build solutions like Jenkins for example.

A tail of two worlds





  • A working Developer Friendly Blueprint see my guide here
  • A system with a command line that you can run curl from to connect to the vRealize Appliance API
  • An account with access to provision the Developer Friendly Blueprint

Lets get started, first we will need to set some environment variables to save us time. Let’s export the vRA appliance host name.

export VRA=vra-01a.corp.local

Create variable for the HTTP Accept header, which tells the server what format you want the response to be in.

export ACCEPT="application/json"

Here we will authenticate by requesting a bearer token via a POST against /identity/api/tokens API, and we will store the bearer token in a variable so we can use it on future API invocations. This example passes user Tony’s credentials (vsphere.local tenant) with inline JSON, but you could also create variables or store this JSON in a file and use the file instead.

curl --insecure -H "Accept: application/json" -H 'Content-Type: application/json' --data '{"username":"tony@corp.local","password":"VMware1!","tenant":"vsphere.local"}' https://$VRA/identity/api/tokens

Now let’s grab the bearer token from the response above. Highlight all the text between the quotes as shown and copy it to the clip board

Now we will export the token to a variable like below


Now lets test connectivity by listing the entitled catalog items

Notice I add a pipe on the end of the command. This makes the JSON output more readable.  | python -m json.tool

curl --insecure -H "Accept: $ACCEPT" -H "Authorization: $AUTH" https://$VRA/catalog-service/api/consumer/entitledCatalogItems | python -m json.tool

Ok, now that we have connectivity let’s find our catalog item and make a request. Enter the following to bring up the requests view

curl --insecure -H "Accept: $ACCEPT" -H "Authorization: $AUTH" https://$VRA/catalog-service/api/consumer/entitledCatalogItemViews | python -m json.tool

Now let’s locate the URL to get the request form for our CentOS6.3_vRAagent blueprint. Highlight the URL as shown and copy to the clipboard.

Now let’s get the required JSON content to create our request by submitting a curl request and sending the output to a json file

curl --insecure -H "Accept: $ACCEPT" -H "Authorization: $AUTH" https://vra-01a.corp.local/catalog-service/api/consumer/entitledCatalogItems/00608f44-312a-476b-ad78-116b9aea661e/requests/template | python -m json.tool > myrequest.json

view the contents of the output json file by typing cat myrequest.json

Now open the myrequest.json file in the VI editor and click i to insert, scroll down to the GetandRun_1 section and notice the Directory, myscript and wgetURL sections. Fill them in as shown with your information

Press ESC then hold shift and press ZZ to save the file.

Now let’s create the request. We need the request URL so enter the following again and locate the request URL highlight it and copy to the clipboard

curl --insecure -H "Accept: $ACCEPT" -H "Authorization: $AUTH" https://$VRA/catalog-service/api/consumer/entitledCatalogItemViews | python -m json.tool

Now let’s create and invoke the request using the following and press enter Note: below the items in red that you will need to input for your environment.

Note: below the items in red that you will need to input for your environment.

curl --insecure -H "Accept: application/json" -H "Authorization: $AUTH" https://vra-01a.corp.local/catalog-service/api/consumer/entitledCatalogItems/00608f44-312a-476b-ad78-116b9aea661e/requests --data @myrequest.json --verbose -H "Content-Type: application/json" | python -m json.tool

You can use the following to view the requests

curl --insecure -H "Accept: $ACCEPT" -H "Authorization: $AUTH" https://$VRA/catalog-service/api/consumer/requests | python -m json.tool

Or go to the portal

Now that you can request a blueprint from the API as well as push scripts into that guest OS and run commands you can take it even further and create multiple requests ad link them together. For example if you wanted to create a multi-tiered app you could create a request for an Apache Web Server, Oracle DB and Tomcat server.

Enjoy and Happy coding.

Remember sharing is caring!

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.