Experimenting with the REST API – What Tools can I use? – Part V

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 :

  1. 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
  2. Next we Add the plugin to Firefox by clicking the “Add to Firefox” button (as shown below)
  3. Confirm Installation when prompted
  4. Restart Firefox to complete the installation

FF-SS

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.

FF-SS-1

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.

RESClient-Vanilla

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

RESTClient-Auth

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:

RESTClient-Basic-Auth

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 :

RESTClient-Auth-Error

Step 3. Once you have entered the Basic Authorization details you will see that the Authorization has now been added under the Headers section:

RESTClient-Auth-Header

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:

RESTClient-Request

This will result in the following, providing you have provided the correct Authorization details. What I am showing you below is just the “Response Header”.REST-API-Response-Header

Select the “Response Body (Highlight)” to show the baseUri of the API versions supported. Here is an example (truncated) :

REST-API-Versions

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 :

  1. Determine what the current configuration of the syslog server is
  2. 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).

REST-Syslog

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 :

Curl-Version

Here is the REST Request and REST Response :

REST-Curl-Response-Update

Note the following above which I have highlighted in ‘Red’.