This is a migrated thread and some comments may be shown as answers.

Fiddler Script save response body to same file

2 Answers 611 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
a
Top achievements
Rank 1
a asked on 28 May 2020, 02:10 PM

Hello

Is it possible to save the captured data to one file named "output.txt" and keep overwriting that file for every subsequent write.

So I will always have just one file which will be over-written each time.

Below is my code which generates different files with different filenames.

 

    if (oSession.PathAndQuery.ToLower().Contains("iva/subscriptions"))
        {
            if(oSession.responseCode == 200)
            {
                var directory2 = "C:\\aos";
                var filename2 = oSession.oRequest.headers['SOAPAction'].ToString().Replace('"','') + "_" + Guid.NewGuid();
                var path2: String = System.IO.Path.Combine(directory2, filename2);

                //oSession.SaveRequestBody(path2 + "_request.txt");
                oSession.SaveResponseBody(path2 + "_response.txt");
               
            }
        }

 

Thank you

2 Answers, 1 is accepted

Sort by
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 02 Jun 2020, 12:56 AM

Hi a,

Thank you for providing your code. This would need to be used in the OnBeforeResponse Handler available in the FiddlerScript Editor. See the Understanding FiddlerScript and the below code snippet for more information. 

public static void OnBeforeResponse(Session oSession)
{
	if (oSession.PathAndQuery.ToLower().Contains("iva/subscriptions"))
	{
		if(oSession.responseCode == 200)
		{
			var directory2 = "C:\\aos";
			var filename2 = oSession.oRequest.headers['SOAPAction'].ToString().Replace('"','') + "_" + Guid.NewGuid();
			var path2: String = System.IO.Path.Combine(directory2, filename2);
	
			oSession.SaveResponseBody(path2 + "_response.txt");
	               
		}
	}
}

Please let me know if you need any additional information. Thank you for using the Fiddler forums.

Regards,


Eric R | Senior Technical Support Engineer
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
a
Top achievements
Rank 1
answered on 02 Jun 2020, 03:54 PM

Hi Eric

Great stuff, thanks a lot.

 

Tags
Fiddler Classic
Asked by
a
Top achievements
Rank 1
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
a
Top achievements
Rank 1
Share this question
or