My favourite tool for testing RESTful services is the Chrome plugin, “REST Console”. Since ServiceStack is an ideal framework to build REST APIs, REST Console is an excellent tool to accompany ServiceStack. Let’s see how to use free Chrome REST Console tool to test a service. For this demonstration, I am going to use the simple Flight Service that I created previously.
First and foremost, we must install REST Console into Chrome browser. If you don’t have Chrome browser installed in your computer please download it from Google and install it first. Visit www.google.com using Chrome browser and search for “Chrome Web Store” and click on the relevant link to visit Chrome Web Store.
Now search for “REST Console” in Chrome Web Store and hit on the +FREE button to install it into the browser.
Now you’ll notice that REST Console is available in your Chrome Apps.
Click on the application icon to launch REST Console. You should now see something similar to the following.
Now, let’s launch the Flight Service that we have created during the previous demonstration.
In this example let’s try to replicate the JSON request through REST Console and see how it works. So, click on the JSON link on the Operations section to view the details that we need to perform a service call to our Flight Service via REST Console.
In order to generate the service URL of the service, we’ll have to combine the base address (http://localhost:63808) with the default service URL (/json/oneway/FlightRequest) so, the complete URL becomes the following.
http://localhost:63808/json/oneway/FlightRequest Please note that the port number of the base address (happen to be 63808 in my local environment) could be a different one if you run this demonstration in your local environment. So, make sure that you replace 63808 with your local port number.Specify the service URL in the Request URI box.
Next, enable the content-type by clicking on the checkbox and then, specify application/json request type.
Finally, we should specify our request payload in JSON format.
Now, we may go ahead and click on the POST button. This will cause REST Console to invoke our Flight Service with supplied request payload and, the resulting response should be observable in the response section.
As we have expected, Arrival and Departure fields are populated from the request that we sent and, values for other properties are also populated. Don’t’ worry about the ArrivalTime and DepartureTime values as those values are encoded in JASON format which is not very readable.