vADC Docs

Tech Tip: Using Stingray's RESTful Control API with the Chrome REST Console

by ricknelson on ‎03-04-2013 12:53 PM (3,383 Views)

Using the Chrome REST Console

The Chrome REST Console is an add-on to the Chrome browser that is very helpful when working with the RESTful API because it makes it easy to retrieve data and see what it looks like. You can also add, change and delete data.  Other tools are available with similar functionality but this article will focus on the Chrome REST Console.  The REST Console can be installed from the Chrome Web Store.

The following are the areas of the Chrome REST Console that must be used for interacting with the RESTful API:

Authorization

The RESTful API uses HTTP basic authentication so an Authentication header must always be set.  You can set this header by pressing the "Basic Auth" button under Authorization and entering the Username and Password.  Press the "Save Defaults" button to save this for future sessions.

scr2.jpg


HTTP Methods

The GET method is used to retrieve resource data, the PUT method is used to add or change a resource and the DELETE method is used to delete a resource.  The method can chosen by pressing the "GET", "PUT" or "DELETE" buttons or by entering the method under Target->Request Method and pressing the "Send" button.

URI

The URI for the resource to be acted on is entered under Target->Target->Request URI.

Other Headers

For requests, the Accept header is optional, but if used should be set to "application/json" for configuration objects or "application/octet-stream" for files.  This header can be set under Target->Accept->Content-Type.

For PUT requests the Content-Type header must be set to "application/json" for configuration objects or "application/octet-stream" for files.  This header can be set under Body->Content Headers->Content-Type.

PUT Data

To add or change data for a resource, you must enter the request body under Body->Request Payload->RAW Body.  For configuration objects, this data must be entered in JSON format, for files it will be the raw file content.

scr1.jpg

scr3.jpg

Response Data

The response data will be displayed in the Response section.  Note that the HTTP status code is not displayed, but in case of an error the error message returned in the response will be displayed.  For a successful DELETE request, the response will empty.

scr4.jpg

Read more

Tech Tip: Using Stingray's RESTful Control API