Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compose request for REST web method in fiddler

I am able to call web serivce but name property is not binding.

Fiddler request

POST http://localhost:50399/api/custservice/ HTTP/1.1
User-Agent: Fiddler
Host: localhost: 50399
Content-Length: 28
{ "request": { "name":"test"}}

POST Webmethod

public string Any(CustomerRequest request)
{
  //return details
}

CustomerRequest.cs

public class CustomerRequest 
{
  public string name {get;set;}
}
like image 887
Sunny Avatar asked Mar 14 '13 15:03

Sunny


People also ask

How do I add a request method in Fiddler?

To create a GET request inside Fiddler, choose the GET method and type the server URL in the URL box. Then click the Execute button. NOTE: Once the request is sent to the server, use the Inspectors to inspect the response. There is a different inspector type for almost all response content types like JSON, Web, etc.

How do I record API calls in Fiddler?

Run fiddler to start capturing web requests/responses made by various client applications on your system (e.g. Curl, Chrome, Internet Explorer). To start/stop capture go to File > Check/Uncheck [Capture Traffic] option. By default when you run Fiddler it behaves like the default proxy server on your system.

Which tab builds a raw HTTP request in Fiddler?

The Fiddler Everywhere HTTP(S) Inspectors tab renders the Request and the Response sections, which display the request and the response information for the HTTP(S) sessions that are selected from the Live Traffic list.

How to use Fiddler to send HTTP request to local API services?

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.

How do I use composer inside fiddler everywhere?

The Composer inside Fiddler Everywhere allows you to create requests to REST and SOAP API endpoints. Requests made to local and online APIs enable you to check and debug various endpoints, inspect and analyze requests and responses, and retrieve and receive data quickly. Select an appropriate HTTP method and enter the endpoint URL.

How to view uncompressed HTTP response in Fiddler?

View HTTP Response in Fiddler. 1 Click on the web request entry on left pane. 2 Click on the Inspector Tab > Click Transformer tab from bottom panel. 3 Click on transformer tab and select No compression option and then click Raw tab View uncompressed data in Fiddler (GZip, Deflate Encoding)

What is a POST request in Fiddler?

These requests are used when you want to send data back to the server. The most common usage is when you submit a form in a website. To send a new POST request, choose POST for method type, type the URL, enter the body content and click Execute. Fiddler can create any type of request that is supported by the HTTP standard in a similar manner.


1 Answers

First of all you need to add Content-Type 'application/json' to the request:

POST http://localhost:50399/api/custservice/ HTTP/1.1
User-Agent: Fiddler
Host: localhost: 50399
Content-Type: application/json

Then change your POST data to:

{"name":"test"}

You will be able to access the data using:

public string Any(CustomerRequest request)
{
  return request.name
}

Alternatively using your existing POST data structure create a new class:

public class RequestWrapper
{
  public CustomerRequest request { get; set; }
}

and change your Action method to:

public string Any(RequestWrapper wrapper)
{
  return wrapper.request.name;
}
like image 74
Jon Susiak Avatar answered Oct 01 '22 10:10

Jon Susiak