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;}
}
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.
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.
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.
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.
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.
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)
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.
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With