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

I have a valid JSON, I want to use POST it using Fiddler and it is not working.

1 Answer 451 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Forbannet
Top achievements
Rank 1
Forbannet asked on 11 Jun 2017, 06:33 PM

I have a rule my fiddlerscript that does the following

if (oSession.utilFindInRequest("mything",false) > 1) {
.SaveResponseBody("c:\\myjson\\" + oSession.SuggestedFilename);
}

It works PERFECTLY well. It saves a the file as TXT, but inside the file it is a JSON, valid JSON. So I use a programm I made in C# that basically reads the files on this folder, and POSTS it to a PHP script I have and this PHP inserts into a mysql database.

 

But I would like to make Fiddler inject direct into my website. So I tried some workaround like creating a XMLRequest inside my rule in fiddlerscript

 

fb1 = new ActiveXObject("MSXML2.ServerXMLHTTP.3.0");

[blablabla]

And it works (does create the request)

but my PHP gets the request corrupted (because the json have some # and & and empty stuff etc). The problem is probably with the XMLHTTP3.0.

 

So I am trying to have my RESPONSEBODY encoded as base64 or something else, and Eric once posted the following for a different user

 

"nstead, keep the bytes as bytes

        // Remove chunking & compression
oS.utilDecodeResponse(); 

        // Get raw bytes
        byte[] arrBody = oS.responseBodyBytes;

        // Convert to base64
        string sBase64 = Convert.ToBase64String(arrBody);"

 

But I cannot use this line (        byte[] arrBody = oS.responseBodyBytes;  ) it does not compile.

also when I base64 encode using

var obytes = System.Text.Encoding.UTF8.GetBytes(oSession.responseBodyBytes);

var base64 = Convert.ToBase64String(obytes);

 

if I log this base64 var to CONSOLE (Fiddler) and then Decode, it works well (Valid JSON) but if I use once again my XMLHTTPREQUEST it corrupts the JSON.
The problem is with the XMLHTTPREQUEST then, how do I inject a valid JSON from Fiddlerscript to my PHP page? without messing it up because once again, my JSON has symbols like # and a lot of \/ (slashes) that the XMLHTTPREQUEST removes.

 

1 Answer, 1 is accepted

Sort by
0
Forbannet
Top achievements
Rank 1
answered on 11 Jun 2017, 07:37 PM
I figured out the main issue, this JSON is quite big and also has XML inside it lol. The XML part is messing up
Tags
Fiddler Classic
Asked by
Forbannet
Top achievements
Rank 1
Answers by
Forbannet
Top achievements
Rank 1
Share this question
or