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

JSON object modified request with headder

3 Answers 914 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Billy
Top achievements
Rank 1
Billy asked on 24 Sep 2019, 02:45 AM

Ive created a fiddlescript rule with the help of many people on this fourm, thank you.

The script would check for a specific json object from the get request in the decoded response body from an application and once the request response body has found   object:value, automatically send the a portion of the json value back to a different URI as a post request with the same header information such as cookies along with connection keep alive.

When the script is activated upon arrival of said content I receive an error. I assume its something to do with the json object value.

static function OnBeforeResponse(oSession: Session) {
    if (oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/json")) {
        oSession["ui-backcolor"] = "blue";
        oSession.utilDecodeResponse();
    }
    if (oSession.oResponse.headers.ExistsAndContains("Content-Type", "application/json") && oSession.utilFindInResponse("faceId", false) > -1) {
        oSession["ui-backcolor"] = "green";
        oSession.utilDecodeResponse();
        var oBody = System.Text.Encoding.UTF8.GetString(oSession.requestBodyBytes);
        var j = Fiddler.WebFormats.JSON.JsonDecode(oBody);
        var facId = j.JSONObject["faceId"];
        var reqBod = '{"faceId":"' + facId + '"}';
        oSession.oRequest.headers.HTTPMethod == "POST";
        oSession.utilSetRequestBody(reqBod);
        oSession.url = "https://urltosendpostrequest.com/Search";
        FiddlerObject.utilIssueRequest(oSession);
    }

Ive been referencing many different pages and fiddlerscripts on this topic and have gotten this far only from a little knowledge of coding and much googling. One code stood out. I dont take credit for this.


3 Answers, 1 is accepted

Sort by
0
Billy
Top achievements
Rank 1
answered on 24 Sep 2019, 02:50 AM
No editing on these coding fourms, lol what a shame. Admin please remove second code as I did not realize it has sensitive information that most likely has already been cached.
0
Billy
Top achievements
Rank 1
answered on 24 Sep 2019, 05:26 PM
Admins skipping this thread in order to reply to other threads with a generic response. Please do your job its Tuesday.
0
Simeon
Telerik team
answered on 25 Sep 2019, 11:21 AM

Hello Billy,

The code was removed.

Regards,
Simeon
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Fiddler Classic
Asked by
Billy
Top achievements
Rank 1
Answers by
Billy
Top achievements
Rank 1
Simeon
Telerik team
Share this question
or