• Home
  • About
  • Contact
  • ado.net
  • angular
  • c#.net
  • design patterns
  • linq
  • mvc
  • .net core
    • .Net Core MVC
    • Blazor Tutorials
  • sql
  • web api
  • dotnet
    • SOLID Principles
    • Entity Framework
    • C#.NET Programs and Algorithms
  • Others
    • C# Interview Questions
    • SQL Server Questions
    • ASP.NET Questions
    • MVC Questions
    • Web API Questions
    • .Net Core Questions
    • Data Structures and Algorithms

Friday, April 17, 2020

How to use Fiddler to test Web API

 Admin     April 17, 2020     .Net, Web API     No comments   

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 the same example.

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.
Fiddler to test Web API
Fiddler UI
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.
Hiding all fiddler processes
Hiding all fiddler 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.
Execute a request in Fiddler
Execute a request in Fiddler
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.
Response in Fiddler
Response in Fiddler
Understanding Fiddler Request and 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.
Understanding Fiddler Request and Response
Understanding 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.
Fiddler Request & Response in Raw Format
Fiddler Request & 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.

Testing POST Request using Fiddler:
  • Select the Compose Tab,
  • Then choose the HTTP verb as POST
  • Set the Content-Type as application/JSON.
  • In the request body, provide the string value that you want to add into the string array.
  • Click on the Execute button as shown below.
Testing POST Request using Fiddler
Testing POST Request using Fiddler
Testing PUT Request using Fiddler:
  • Select the Compose Tab,
  • Then choose the HTTP verb as PUT
  • In the URL provide the index of the array element whose value you want to update.
  • Set the Content-Type as application/json.
  • In the Request body, provide the updated string value that you want to update into the string array.
  • Finally, click on the Execute button as shown below.
Testing PUT Request using Fiddler
Testing PUT Request using Fiddler
Testing DELETE Request using Fiddler:
  • Select the Compose Tab,
  • Then choose the HTTP verb as DELETE
  • In the URL provide the index of the array element whose value you want to update.
  • Finally, click on the Execute button as shown below.
Testing DELETE Request using Fiddler
Testing DELETE Request using Fiddler

Summary:
I Hope this post will be helpful to understand the concept of using Fiddler to test Web API
Please share this post with your friends and colleagues.
For any queries please post a comment below.
Happy Coding 😉
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post

0 comments:

Post a Comment

If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.

Join us on Telegram

Loved Our Blog Posts? Subscribe To Get Updates Directly To Your Inbox

Like us on Facebook

Popular Posts

  • What is Dependency Injection(DI)
    Hi friends! Today we are going to learn about Dependency Injection and in our last session we have come across Static classes and where it s...
  • C# Programming Examples on Sorting
    Today i am going to tell you some of the Sorting programming questions in C#. Q1- Write a C# program to perform Selection sort. Ans:  Sel...
  • Calling Web API Service in a Cross-Domain Using jQuery AJAX
    In this article, I am going to discuss Calling Web API Service in a Cross-Domain Using jQuery AJAX . Please read our previous article befor...
  • ViewBag in ASP.NET Core MVC
    In this article, I am going to discuss the use of ViewBag in ASP.NET Core MVC application with examples. Please read our previous article ...
  • Recursion And Back Tracking
    In this article, I am going to discuss Recursion And BackTracking in detail. Please read our previous article where we discussed Master Th...
  • What is Abstract Class and When we should use Abstract Class
    Hi friends! In our previous sessions we have seen  Difference Between Class and Struct . And in our last session  we learnt Usability of Sec...
  • Binary to Decimal Conversion in C# with Examples
    In this article, I am going to discuss the Binary to Decimal Conversion in C# with some examples. Please read our previous article where w...

Blog Archive

Contact Form

Name

Email *

Message *

Tags

.Net .Net Core .Net Core MVC Algorithm Angular Anonymous Types Asp.Net Asp.Net MVC Blazor C# Data Structure Database Design Patterns Entity Framework Entity Framework Core Filters Interview Question Management Studio Programming Programs SQL Server SSMS Web API

Copyright © C# Techtics | All Right Reserved.

Protected by Copyscape