Author : Michael A. Haines
In this blog post we are going to continue looking at the common tools that enable you to interact with the REST API and in particular the Firefox RESTClient 2.0.3 Extension. We will cover :
- Installing the REST Client Firefox Plugin
- Using the REST Client Firefox Plugin
So, to start with lets take a look at Installing the REST Client Firefox Plugin. We start by :
- Locating the latest version (2.0.3) of the REST Client by searching Add-ons from the Firefox website. https://addons.mozilla.org/en-US/firefox/addon/restclient/?src=ss
- Next we Add the plugin to Firefox by clicking the “Add to Firefox” button (as shown below)
- Confirm Installation when prompted
- Restart Firefox to complete the installation
Now we have successfully installed the RESTClient Firefox Plugin we can now start to use it. To begin, we need to start the RESTClient from Firefox Tools menu as show below.
Once you have started the RESTClient you will be presented with the following interface as shown below. As you can obviously see, you now need to configure this interface to use the RESTClient.
So, in order to use RESTClient what exactly do I need to configure? There are two basic elements that need to be configured in the RESTClient. These are Authentication and Headers. Let us start with configuring the RESTClient Authentication which is described below.
Step 1. Select the Authentication tab and then Basic Authentication
Step 2. You will then be prompted with the following interface where you will be required to enter the Basic Authorization details as in the following example:
Recall that with NSX for vSphere (as I am using in this example) all REST API requests require authentication. Also note here that no validation is performed when you enter the username and password. So be careful when you enter these details else you will observe something like the following when you start to issue REST Requests :
Step 3. Once you have entered the Basic Authorization details you will see that the Authorization has now been added under the Headers section:
Next, you will need to specify content-type header when sending REST requests.
So even at this stage and only entering just the Authorization details, we are actually now ready to start issuing REST Requests! As an example, and if you have read previous posts, you will know I always start with my REST ping example!, which is where we will issue a REST request to enumerate the supported NSX for vSphere API versions:
Select the “Response Body (Highlight)” to show the baseUri of the API versions supported. Here is an example (truncated) :
Let us now turn our attention to the “Headers” section of the REST Client. We are going to use the NSX for vSphere Manager and Syslog server configuration as an example. Here we want to :
- Determine what the current configuration of the syslog server is
- Add our own syslog server configuration
Let us start with determining what the current syslog configuration is. I will also just to mix this up a little show you how to achieve the same but instead of using the REST Client, using the command-line and curl(1).
Ok, what is the first thing you recognise? The REST Request was successful (take my word for it here) but nothing was returned! That is because syslog is NOT configured! Here is the same REST Request and Response, but in this example we are using curl(1).
This is the curl(1) version we are using :
Here is the REST Request and REST Response :
Note the following above which I have highlighted in ‘Red’.