9

I need to record how my client side scripts act in a 3rd party web app. So I am trying to use Fiddler to record the traffic on the 3rd party's machine and then run it here.

Sounds great, but my scripts make AJAX calls to an ASPX (123.aspx) page, and the calls use only POST params, not GET.

This means that the (123.aspx) request URLs recorded in Fiddler are identical, and playback doesn't work properly (every AJAX request matches the first recorded match, not the one with the same POST params).

 E.g. let's says the requests are recorded like this
 123.aspx [POST param: searchquery=xyz]
 123.aspx [POST param: searchquery=abc]

then when I playback the SAZ file, I always get the response for 123.aspx [POST param: searchquery=xyz], even if searchquery=abc.

How can I get Fiddler to treat requests differently if the POST params are different?

I saw extraction rules, and was a little unsure about them, the Telerik documentation returns no results for 'extraction'... are they what I need?

Thanks

  • I ended up modifying the script to use one of the params as a redundant GET parameter, just to make the URLs unique. This obviously required work at the 3rd party's end, so I'm still curious if this could have been achieved without a modification to our script? – Jim W says reinstate Monica Mar 24 '14 at 16:02
  • Fiddler records the complete URL as well as the complete POST body. What exactly do you mean when you say *then run it here*? How are you doing *playback*. Are you asking a question about Fiddler's AutoResponder? When you talk about extraction rules, are you talking about a Visual Studio WebTest script? – EricLaw Mar 24 '14 at 19:10
  • Thanks @EricLaw - I mean (or think I mean) have the 3rd party send me the SAZ file (generated by fiddlercap), and then have the AutoResponder in Fiddler handle requests from my browser - so I can debug our script. So, what was happening is that for subsequent AJAX calls to the same URL (different post params) the AutoResponder matches the first AJAX call only. As for extraction rules, yes I was probably confusing VS web test - I thought I saw something on the web about extracting POST params... – Jim W says reinstate Monica Mar 25 '14 at 03:12

1 Answers1

8

Please see the introductory blog post for details about Fiddler AutoResponder's Import for Playback mode which helps address some problems you may encounter when trying to playback a previously-captured SAZ file.

Now, the "Import for playback" mode will not address all possible problems; for instance, if you have multiple POSTs to the same URL captured but their ordering is not the same as was captured when you try to replay the scenario, they will play back in the wrong order and things will be broken.


From the Fiddler Book:

Matching Against Request Bodies

In some cases, a site may use the same request URL for many unrelated operations, specifying the operation desired in the request’s body instead of the URL. You may extend your Match Condition to examine a POST or PUT request’s body by specifying the URLWithBody: prefix for your Match Condition. When this prefix is used, the portion of the string up to the first space character is used as the Match Condition for the request’s URL, while the remainder of the string is used as a Match Condition for the string-representation of the request’s body. For performance reasons, you should specify the URL portion of the Match Condition as narrowly as possible to minimize the number of request bodies that the AutoResponder needs to evaluate. If a request has no body, it will not match any URLWithBody rule.

Your Match Condition may specify the EXACT:, NOT:, and REGEX: prefixes for both the URL and the body. For example:

URLWithBody:upload.php TextToFindInBody
URLWithBody:login.php EXACT:Action=Login
URLWithBody:ping.php NOT:POST Data I Do Not Care About
URLWithBody:EXACT:https://example.com/upload.php REGEX:^.+TextToFind.*$
URLWithBody:REGEX:^.+/upload.php.*$ REGEX:^.+TailOfPOST$

Keep in mind that most POSTs from Web Forms encode the body text, so you should ensure that your Match Condition accounts for such encoding. For instance, to match the following POST:

POST http://www.enhanceie.com/sandbox/FileForm.asp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 54

2=This+is+some+text&fileentry2=&_charset_=windows-1252

Your Match Condition should be:

URLWithBody:/sandbox/FileForm.asp This+is+some+text
EricLaw
  • 54,427
  • 7
  • 140
  • 182
  • Hey Eric, I'm experiencing an odd behavior (or I'm misundertanding). I've set a `URLWithBody` and just below a `*bpu`. End up if in the `*bpu` I select to `Run to completion` with a predefined response looks like it ignores the `URLWithBody` rule. – Vitor Canova May 29 '14 at 13:33
  • 1
    Hey, @VitorCanova: As this is a different question, please post it in the Fiddler discussion group or as a new question here. Please use CTRL+C to copy the full text of both rules so I can be sure of what your scenario is. Thanks! – EricLaw May 29 '14 at 14:56
  • By "Fiddler discussion group" you mean post here at SO with `Fiddler`tag? – Vitor Canova May 29 '14 at 15:04
  • 1
    In Fiddler, click `Help` > `Fiddler Community Discussions`. Or just post here with the `Fiddler` tag. – EricLaw May 29 '14 at 15:27