Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Post request in Fiddler

trying to send a Fiddler Post request to my C# API as follows (this is my dev environment using VS2012). However, my request object is null in C#. In the parsed tab of the composer tab. My post URL: http://localhost:33218/api/drm

User-Agent: Fiddler/4.4.9.2 (.NET 4.0.30319.34209; WinNT 6.1.7601 SP1; en-US; 4xAMD64)
Pragma: no-cache
Accept-Language: en-US
Host: localhost:33218
Accept-Encoding: gzip, deflate
Connection: Close
Content-Length: 80

Request Body:

&sid=f7f026d60bb8b51&riskMeasureName=RMTest

And here's the C# API method:

// POST api/drm 
public HttpResponseMessage Post([FromBody]JObject drmObject)
{
     string sid = drmObject.GetValue("sid").ToString();
     string riskMeasCategory = drmObject.GetValue("riskMeasureName").ToString();
     string response = DynAggrClientAPI.insertDRMCategory(sid, riskMeasCategory);

     var httpResp = Request.CreateResponse(HttpStatusCode.OK);
     httpResp.Content = new StringContent(response, Encoding.UTF8, "application/json");

     return httpResp;
}

I can debug in my C# Post() method, but the drmObject is null.

Your advice is appreciated.

like image 472
bob.mazzo Avatar asked Mar 19 '15 20:03

bob.mazzo


People also ask

How do I hold a request on Fiddler?

Capture a request using Fiddler. Select the request, right-click, and click Replay > Reissue Requests (Or just click and type R). Select multiple requests and do the same steps. The same request can be run many times using this method.

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 do I add a header in Fiddler?

The session opens in a new Composer window and then you can change the desired values. For example, change the data payload, modify the headers, test the authentication, and so on. To modify a header, select it and change the needed key-value pair. You can add a new header by using the top key-value row.


1 Answers

You're not sending a content-type, so MVC has no way to tell how to interpret the data.

Your data seems to resemble a form POST, so add the header:

Content-Type: application/x-www-form-urlencoded
like image 83
CodeCaster Avatar answered Sep 30 '22 10:09

CodeCaster