Using Fiddler with Web API

Leave a comment

In this post, we will examine using Fiddler to send requests and receive responses from an ASP.NET Web API.

I have a Web API sample that looks like the following:

There are different HTTP verbs, including:

  • GET
  • PUT
  • POST
  • DELETE

The Customers API is very simple – it integrates with a SQL Server table called Customers with 2 fields – CustomerId and CustomerName, with the data:

Start Fiddler. We will filter the Fiddler traffic to only show Intranet Hosts, as we are running this test on an intranet:

If we view http://localhost:31404/api/Customers we can see all (2) customers have been returned:

We can get one Customer with the request /api/Customers/1:

We can create our own requests using Fiddler by clicking on the Composer tab:

If we want to send the same HTTP GET request, we can enter our URL http://localhost:31404/api/Customers/1 and GET, then Execute:

We can see the raw request and response as well:

From our API, we have the POST URL as api/Customers and the Body parameters:

Our header will look like this:

User-Agent: Fiddler
Host: localhost:31404
Content-Length: 49
Content-Type: application/json; charset=utf-8

Note the Content-Type line.

We will supply these parameters to our POST request in the Body. When we execute this, we will see a 201 (Created) response:

With the line added to the database:

To DELETE the same customer:

And to update a customer using PUT:

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

Leave a Reply

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