Cher
Cher

Reputation: 2937

How to Get the HTTP Post data in C# - FiddlerCore?

I am using Fiddler.

When I capture a request, it's a Fiddler.Session object.

I've been searching this object for hours now, and I can't find the Request Payload.

I have searched through all properties, maybe I skipped something, but I can't find it. I searched more RequestBody and RequestHeaders without success.

This site explains about the Fiddler functions:

https://weblog.west-wind.com/posts/2014/jul/29/using-fiddlercore-to-capture-http-requests-with-net

So for example I would like to do the following:

private void FiddlerApplication_AfterSessionComplete(Session sess)
{
  string payload = sess.??? //Where the property would be the POST data
}

Is it possible it's just not there?

Upvotes: 2

Views: 929

Answers (1)

Nkosi
Nkosi

Reputation: 247058

Provided the session parameter is for a POST request you would get the body of the request in the sess.GetRequestBodyAsString();

private void FiddlerApplication_AfterSessionComplete(Session sess) {
    if (sess == null || sess.oRequest == null || sess.oRequest.headers == null)
        return;

    string reqHeaders = sess.oRequest.headers.ToString(); //request headers        
    var reqBody = sess.GetRequestBodyAsString();//get the Body of the request
}

Upvotes: 2

Related Questions