Showing posts with label Fiddler. Show all posts
Showing posts with label Fiddler. Show all posts

Saturday, January 30, 2016

Step by step how to send an HTTP DELETE Request to an RESTful WCF Service using Fiddler

In this tutorial we'll learn how to create an HTTP DELETE Request to an RESTful WCF application using Fiddler
We'll use Fiddler for testing purposes of a RESTful WCF application, sending  HTTP DELETE requests. We'll start with a WCF application,  and we'll remove an entry using Fiddler, showing as follows :





First of all, we have to download the FREE Fiddler tool from this web site :



Now check the settings of the Operation Contract at the WCF Service Contract, in order to provide exactly what it is expected:



The WebInvoke is set to handle the DELETE HTTP method, and the request format is supposed to be JSON, the same as the response format. So, we'll send what the WCF wants.
Open Fiddler and find the "Composer" option:




Then type in the WCF service URL and select "DELETE" HTTP method from the list. Set the request Headers as follows: (the Content-Length  will be filled by Fiddler for you):



Fill the Request Body, and take care to fill the ID of the record to remove. The rest of fields is just optional.

Press the "EXECUTE" button  to send the request. If you set a breakpoint inside the WCF operation, you'll see the following in action :


As you see, WCF succeeded at identifying inside the JSON the ID to erase.
Then the response is sent to Fiddler, with a "true" value, because everything went fine:


And the database shows the deleted value:



If you want to see the RESTful WCF that we're using here, see this tutorial.

That's all.... 
In this tutorial we've seen how to send an HTTP DELETE Request to an RESTful WCF service using Fiddler. 
Happy programming.....
      By Carmel Shvartzman
כתב: כרמל שוורצמן








Saturday, November 29, 2014

Step by step how to send an HTTP PUT Request to a RESTful WCF Service using Fiddler

In this post we'll learn how to send an HTTP PUT Request to a RESTful WCF application using Fiddler
We'll use Fiddler to test an RESTful WCF application, sending an HTTP PUT request. We'll start with a working WCF application,  and we'll update an entry using Fiddler, showing as follows :



First of all, we have to download the FREE Fiddler tool from this web site :



After installing it , study the settings of the Operation Contract at the WCF Service Contract, in order to fill exactly what it is expecting as a request:
http put request to restful wcf using fiddler

The WebInvoke handles the PUT HTTP verb, and the request format must be JSON, and so the response format. Therefore, we'll send exactly what the WCF wants.
Open Fiddler and click the "Composer" option:




Then type in the URL and select "PUT" HTTP request method from the list. Also, set the request Headers as follows: (don't worry about the Content-Length, because Fiddler will fill  it for you):



Also, fill the Request Body :  be careful to fill adequately the field names of the Entity you want to update, most of all, the ID of the record to change.

Press the "EXECUTE" button at the Fiddler Composer, to send the request. If you set a breakpoint inside the WCF HTTP PUT handler, you'll see the bindings in action :


As you see, WCF succeeded at binding the JSON it got with the Blog object expected.
The response is then sent to Fiddler, with an "true" value:


And the database shows the updated values:



If you want to take a look at the RESTful WCF which we're using here, see this tutorial.

That's all... 
In this tutorial we've learned how to send an HTTP PUT Request to a RESTful WCF application using Fiddler. 
Happy programming.....
      By Carmel Shvartzman
כתב: כרמל שוורצמן










Tuesday, June 10, 2014

Step by step how to create a POST Web Request using the Fiddler application

       By Carmel Shvartzman
In this tutorial we'll learn how to send a POST Web Request using the Fiddler tool and an Asp.Net MVC application
We'll start with a working MVC application, which uses an SQL database, containing a Posts Controller to support all CRUD operations, and we'll create a new entry using Fiddler, showing as follows :



First of all, to create the POST request, we need to download Fiddler from this web site :


After installing it on your machine, open Fiddler and click the "Composer" window :



Then type in the URL and select "POST" request method from the list :


Also, add the HOST, ACCEPT, and CONTENT-TYPE Headers for the request (don't worry for the Content-Length, because Fiddler will count and fill that field).

Then, fill the Request Body :  be careful to respect the field names of the Entity you want to create, because MVC will try to bind your request body to the fields of the Entity according to field names and types :



If the Operation Contract (the WCF method which handles this HTTP verb) has been defined using the "RequestFormat" option as "JSON", we can send a JSON body with our request, as follows:




Press the "EXECUTE" button at the Composer, to send the request. If you set a breakpoint inside the POST Controller Action, you'll see the binding in action :



In the meantime, you can see the HTTP request sent by Fiddler :


Also, the request's body fields can be seen in Fiddler : in the "WebForms" tab of the "Inspectors":



After the request has been processed, the new entry is appended to the posts list, and appears in the main page:


That's all!! 
In this tutorial we've seen how to create a POST Web Request using the Fiddler application and an Asp.Net MVC application. 
Happy programming.....


כתב: כרמל שוורצמן