How to edit body before send request with Fiddler(script)
in my case path /login have body username: xxx pass: xxxx
how to edit user pass before send send request
How to edit body before send request with Fiddler(script)
in my case path /login have body username: xxx pass: xxxx
how to edit user pass before send send request
On
static function OnBeforeRequest(oSession: Session) {
var loginDomain = 'www.testlogin.org';
var loginPath = '/login';
var username;
var password;
var strBody
if (username == null && oSession.uriContains(loginDomain) &&
oSession.uriContains(loginPath))
{
username = FiddlerObject.prompt("Enter user name: ");
password = FiddlerObject.prompt("Enter password: ");
strBody='username: ' + username + ' pass: ' + password;
//encode the body to handle special characters in the password
//password "P&ssword=secure" will be "P%26ssword%3Dsecure"
strBody=Utilities.UrlEncode(strBody);
oSession.utilSetRequestBody(strBody);
}
//... the rest of the OnBeforeRequest function
}
This will open 2 prompt windows to enter the username and then password after entering the login URL in a browser and executing a request. The prompts may not popup in front of the browser, you may need to switch focus to fiddler to use the prompt windows
For modifying requests in Fiddler classic use the
OnBeforeResponsefunction. To replace username and password in body of the HTTP request (not in header as used e.g. by BASIC auth) you can useutilReplaceInRequestmethod which performs search and replace on text level:Alternatively you can get the body as text and manipulate it as you want using standard .Net String methods: