Thursday, March 19, 2015

Testing your ASP.NET Web API RESTful Services

Since ASP.NET Web API works using RESTful Urls, it becomes relatively easy to test your ASP.NET Web API Services using a variety of tools.

The most common tool that I use is Telerik Fiddler:

However, Fiddler is pretty primitive when it comes to composing the Request Body:

There are actually much better tools for composing Requests to ASP.NET Web API Services and most of these are all available as Free Extensions/Apps for Google Chrome!

One of my favorite tools is Postman REST Client:

Here are screenshots of using Postman for GET and POST requests:

The really great thing about Postman is that it allows you to compose Headers as well as Form Body Requests as a series of Key-Value pairs which is much easier to understand than attempting to compose these values in their Raw form which involves the appropriate concatenation of values in the Request Body as well as manually typing in the values for the various available Request Headers.

There are a few things about Postman that require a bit more intricate knowledge of how to manage requests to RESTful Services such as whether to post as form-data, x-www-form-urlencoded data or raw data, but playing with these settings a bit will allow you to figure out which setting is most suited for your testing.

Overall, Postman is much more user friendly and feature-rich than Telerik Fiddler.  It even has special support for testing OAuth 1.0 and OAuth 2.0!

If you search the Google Chrome Web Store, there are actually a wide variety of REST Clients available that you can choose based on your own preferences:

These are just a few of the other REST Clients:

No comments:

Post a Comment