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

Find Json data and replace it.

2 Answers 460 Views
Extensions and Customization
This is a migrated thread and some comments may be shown as answers.
Geneilson
Top achievements
Rank 1
Geneilson asked on 22 Apr 2020, 05:33 PM
01.
if(oSession.HostnameIs("exemple.com")&& oSession.uriContains("login")) {
02.    // Color this response, so we can spot it in Fiddler
03.    oSession["ui-backcolor"] = "lime";
04. 
05.    // Convert the request body into a string
06.    var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
07. 
08.    // Convert the text into a JSON object
09.    var j = Fiddler.WebFormats.JSON.JsonDecode(oBody);
10. 
11.    // Inside of our dictionary, we have an array (ArrayList) called "placements"
12.    var testObject = j.JSONObject["teste"];
13.    /* Change this to different values, e.g. "0.0", 0.0, null, "", etc. */
14.     
15.                   j.JSONObject["auth"]="true";
16.                   j.JSONObject["user"]="false";
17.     
18. 
19.    // Convert back to a byte array
20.    var modBytes = Fiddler.WebFormats.JSON.JsonEncode(j.JSONObject);
21. 
22.    // Convert json to bytes, storing the bytes in request body
23.    var mod = System.Text.Encoding.UTF8.GetBytes(modBytes);
24.    oSession.ResponseBody = mod;
25. 
26. 
27. 
28.}

2 Answers, 1 is accepted

Sort by
0
Geneilson
Top achievements
Rank 1
answered on 22 Apr 2020, 05:36 PM

Script does not currently work, I need help.
If you can help me I will be very grateful.

Thank you.

 

0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 24 Apr 2020, 03:45 PM

Hi Geneilson,

Thank you for providing the code snippet. Although, I am unable to fully understand the issue from the provided code. For example, I can not to see if this is modifying a request or response. In order to fully understand the issue, I will need the following information.

1. Which Fiddler Event Handler this is located in.

2. If there is a specific error you are receiving.

3. If there  is a specific line that isn't working or if the traffic is not modified at all.

Once I have the above information, I will be able to investigate in more detail. For additional information, see the Modify Traffic Reference.

In the meantime, 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.
Tags
Extensions and Customization
Asked by
Geneilson
Top achievements
Rank 1
Answers by
Geneilson
Top achievements
Rank 1
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or