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 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.
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.
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.
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.
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.
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.
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:
Testing PUT 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 😉
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 UI |
Hiding all fiddler processes |
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.
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 |
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 |
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 |
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 |
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 |
- 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 |
- 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 |
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 😉
0 comments:
Post a Comment
If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.