How to use Fiddler to test web API

How to use Fiddler to test web API

In this article, I am going to discuss how to use Fiddler to test web API services. Please Read our creating first web API application article where we discussed the step by step procedure to create ASP.NET Web API application before proceeding to this article as we are going to use the same example. If you want to learn how to use Swagger in Web API to test and document the services then please read our previous article. 

What is Fiddler?

The Fiddler is a free debugging proxy tool which is used for testing restful web services. We can use Fiddler to compose and execute different HTTP requests to our Web API and check the HTTP response.

Let’s see how to use Fiddler to send an HTTP request to our local ASP.NET Web API Services and check the response.

Step1:

Download and install Fiddler from here.

Step2:

Once the Fiddler is successfully installed, click on the Fiddler.exe to open Fiddler. It will look like the image shown below.

how to use Fiddler to test web API

Fiddler by default captures all processes. But here we are not interested in all the processed, we are only interested in capturing our local processes i.e. capturing the WEB API HTTP Resources. So, click on the All Processes button which is at the bottom left corner and select Hide All as shown in the below image. Keep the focus on the Highlighted section.

how to use Fiddler to test web API - Hiding All Processes

Step3:

In the next step, we need to click on the Composer tab. The first tab in the Composer tab is Parsed tab where we can configure the HTTP requests and execute it. The first drop-down includes all HTTP Methods. Select a particular HTTP method for the request you want to execute. Here, we will select the GET HTTP verb to execute HTTP GET request as shown below.

Please keep Focus on the selected section which is in Red Rectangle.

how to use Fiddler to test web API

Now run the web API application and figure out the URL.

Enter URL and Execute

Now, we need to enter the URL of a request in the adjacent text box. Here, we will execute the HTTP request http://localhost:xxxx/api/values to the Web API which we created in the previous article as shown below.

Note: You need to change the PORT Number. Please Keep Focus on the Highlighted section.

how to use Fiddler to test web API - Enter URL and Execute

Response in Fiddler

Once you enter the URL, click on the Execute button to send this HTTP request and it will immediately display the response in the left pane as shown in the below image.

how to use Fiddler to test web API - Response in Fiddler

Fiddler Request & Response

Double click on the result row above (which is highlighted with the red rectangle) to open the Inspector tab for the request as shown below.

how to use Fiddler to test web API - Fiddler Request and Response

As you can see in the above image, the top panel shows the Request header and the bottom panel shows the response body.

Fiddler Request & Response in Raw Format

You can also see the raw request header and response body by clicking on the Raw tab of request and response as shown in the image below.

how to use Fiddler to test web API - Fiddler Request and Response in Raw Format

This is the most preferable way in Fiddler to execute an HTTP request and checking the response. Let’s see how to make a post request using Fiddler.

POST Request:
  1. Select the Compose Tab,
  2. Then choose the HTTP verb as POST
  3. Set the Content-Type as application/json.
  4. In the request body, provide the string value that you want to add into the string array.
  5. Click on the Execute button as shown below.

how to use Fiddler to test web API - POST Request

PUT Request:
  1. Select the Compose Tab,
  2. Then choose the HTTP verb as PUT
  3. In the URL provide the index of the array element whose value you want to update.
  4. Set the Content-Type as application/json.
  5. In the Request body, provide the updated string value that you want to update into the string array.
  6. Finally, click on the Execute button as shown below.

how to use Fiddler to test web API - PUT Request

DELETE Request:
  1. Select the Compose Tab,
  2. Then choose the HTTP verb as DELETE
  3. In the URL provide the index of the array element whose value you want to update.
  4. Finally, click on the Execute button as shown below.

how to use Fiddler to test web API - DELETE Request

In the next article, I am going to How to use Postman to test WEB API services with examples. Here, in this article, I try to explain how to use Fiddler to test web API services. I hope you enjoy this article. 

No HTML was returned.

Leave a Reply

Your email address will not be published. Required fields are marked *