How to create a Post request in Fiddler

11,549

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
Share:
11,549
bob.mazzo
Author by

bob.mazzo

Front-end Developer with full stack experience in c# and Sql Server, working in norther NJ. Current technologies include Angular, Html/JavaScript/CSS, Kendo UI, Angular-Material, Web Api. I'm married with two boys, play piano at church, and do some gigs on the side. I love soccer (Brazil, Man City) - and enjoying training with my kids, and playing with the guys at work. [email protected]

Updated on July 23, 2022

Comments

  • bob.mazzo
    bob.mazzo almost 2 years

    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.