Free Web Development Online Tutorials, Learn to Code
Web API Testing using Fiddler, How to Test Web API

How to test Web API Client using Fiddler

Web API Testing using Fiddler

Now we have learned how to create Web API application, but we have to make sure everything is working as expected, and to do that we need a client that will consume our APIs, developing a testing client app may be time consuming, You don't need to build complex UI fast for testing Web API, there are some ways to test Web API quickly with fiddler.

One Popular way to Test Web API is using Fiddler .

Download Fiddler for Web API Testing

Using fiddler for Web API Client testing

Open fiddler and side by side keep running your web API, so that fiddler can grab the url

Here we will see how to create a new client using web API post method, Below are the new client details in JSON format

    CompanyName:"Web Training Room",
    ContactPerson:"WTR Chakraborty",

Set the Content Type in Fiddler as given below, and set the above client details in Request Body as shown in picture below
Accept : "application/json"
Content-Type: application/json

Once ready click on “Execute” button on right top corner of Fiddler

web api testing using fiddler

Once executed, we have successfully created the new client by calling API Post method from fiddler
Just double click on requested url on left side

web api testing using fiddler

Now think of scenario where you need to test a method which is protected with user name and password , so you must know how to pass user name and password to your API call from fiddler

Now notice, how to pass the authorization credential in screen below

web api authorization testing using fiddler
User-Agent: Fiddler 
Host: localhost:53207
Authorization: WTR d3RydXNlcjp3dHJwYXNz
Authorization: WTR wtruser:wtrpass

Username and password to be encoded in Base64 format, this is how credential string will look like wtruser:wtrpass

Asp.Net Web API Testing Example

C# web service interview questions