FiddlerScript - Changing request help

181 views
Skip to first unread message

Mason Train

unread,
Apr 29, 2018, 9:26:21 PM4/29/18
to Fiddler

I am trying to make a script to change a request before it is sent to my server...
This is in before request


 if (oSession.uriContains("mywebsite"))
        {
            oSession.utilReplaceInRequest("itemID", "6969");
       oSession.utilReplaceInRequest("itemid", "6969");
       
            }

In this case fiddler is changing both names containing itemID or itemid to the value 6969

what I am trying to do is not change the name, but the value associated with that name.

For Example I want it to look like this in the body:

itemID              6969

or 

itemid                    6969


But fiddler is replacing the name instead of the value associated with that name in which case this is the output i get

6969                      (random value)


6969                       (random value)

Hope this makes sense would appreciate any help thanks!

Mason Train

unread,
Apr 29, 2018, 9:50:37 PM4/29/18
to Fiddler
I have gotten further on this problem and I am sooooo close here is my new script: 
 
if (oSession.uriContains("website"))
        {
            oSession.utilReplaceInRequest("itemID=18192", "itemID=6969");
       oSession.utilReplaceInRequest("itemid=18192", "itemid=6969");
       
            }

This replaces the itemIDs value from 18192 to 6969

Which works this is great however I want to be able to change the 18192 value without knowing that its value is 18192
This was the first code I used but this would only add 6969 on top of the 18192 value instead of replacing it

        {
            oSession.utilReplaceInRequest("itemID=", "itemID=6969");
       oSession.utilReplaceInRequest("itemid=", "itemid=6969");
       
            }

What I am trying to do is have it replace ANY value for the itemid I can only get it to do so if I DEFINE the value first, or else it just is added on---

For the code with 18192 defined output

ItemID             6969

And the second code without defining 18192 output

ItemID             696918192

Instead of my desire output from the second code


ItemID           6969


Eric Lawrence

unread,
Apr 30, 2018, 2:36:56 PM4/30/18
to Fiddler
Typically, you use a Regular Expression for this task. FiddlerScript can be written in JScript.NET or C#, and the syntax for each is slightly different. 

If you provide a more complete example of the target request and the desired response, it will allow anyone with knowledge of the language you're using to more easily help you.

The oSession.GetRequestBodyAsString() method will be helpful for you.



You might also consider filing a feature suggestion for a utilReplaceRegexInRequest function to match the existing version that runs on responses: utilReplaceRegexInResponse(sSearchForRegEx sReplaceWithExpression )

Jerry Lee Daniel

unread,
Dec 18, 2023, 4:27:44 PM12/18/23
to Fiddler
For Crypto Trading Investment Guidelines.
Business Administration
📱 Account Management
💳 Entrepreneurship
📈📉 Binary Options/Bitcoin Expert 💰 Loan
Best in stock marketing and Crypto currency investment.

NOTE: ONLY SERIOUS / ACTIVE TRADER CAN CONTACT.

DM ME ON WHATSAPP
+447487588816
Reply all
Reply to author
Forward
0 new messages