SaveResponseBody append mode?

2 Answers 101 Views
Fiddler Classic
Bob
Top achievements
Rank 1
Iron
Bob asked on 28 Sep 2023, 08:51 AM | edited on 28 Sep 2023, 09:04 AM

Hi,

I use OnDone to save responsebodies (mostly json data) that match some URL criteria.
I can set different filenames etc. This works fine.
However, SaveResponseBody overwrites the same file if it exists. 

Basically using something like:

if (oSession.url.Contains("some pattern")) {
var directory: String = "d:\\savedir\\";
var path: String = System.IO.Path.Combine(directory + Guid.NewGuid() + ".json" );
oSession.utilDecodeResponse();
oSession.SaveResponseBody(path);
}

Is there also an append mode available on SaveResponseBody so data is added and not overwritten?

 


2 Answers, 1 is accepted

Sort by
0
Accepted
Nick Iliev
Telerik team
answered on 28 Sep 2023, 09:07 AM

Hey Bob,

 

You can use System.IO methods.

import System.IO

and then

    static function OnDone(oSession: Session) {
        var sw = File.AppendText("D:\\test.txt");
        sw.WriteLine("Some really");
        sw.WriteLine("random");
        sw.WriteLine("Text");
        sw.Close();
    }

 

Regards,
Nick Iliev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Bob
Top achievements
Rank 1
Iron
answered on 28 Sep 2023, 09:33 AM

Thanks

oSession.utilDecodeResponse();
//oSession.SaveResponseBody(path);
var resp: String = oSession.GetResponseBodyAsString();
var sw = File.AppendText("D:\\aos\\test.json");
sw.WriteLine(resp);
sw.Close();
sw.Dispose();

that did it..

 

Tags
Fiddler Classic
Asked by
Bob
Top achievements
Rank 1
Iron
Answers by
Nick Iliev
Telerik team
Bob
Top achievements
Rank 1
Iron
Share this question
or