This Fiddler extension generates C# or VB.NET code to duplicate a web request. You simply drag one or more Fiddler sessions into the newly created “Code” tab or use the ‘r2c <partialURL1> <partialURL2> …’ QuickExec command and the extension will produce appropriate code that you can copy and paste into your program that reproduces those requests.
- C# Code
- VB Code
- POST Data
- Running Code
Download: Fiddler Extension – Request To Code (version 1.8.0, 39.54 kB zipped)
This can be useful for a number of purposes:
- Submit form data programmatically – fill out a form online once with Fiddler running, then use the extension to copy and paste the request code into your own program. You could then make this request as many times and as often as you need to.
- Easily codify web requests – request resources like RSS feeds, images, XML, etc… from your program. Further modify the web requests to your needs.
- Programmatically test differing header values – you can easily modify the request functions so that you can try varying values for various HTTP headers. This way you can test your web site or web service against these various headers.
- Run code directly from the Code tab – you can use the “Run (beta)” button to run the code currently in the Code tab. Just make sure you check the “Usage” option, first.
- Automatically generate code in conjunction with FiddlerCore – Reference both FiddlerCore and FiddlerCoreRequestToCode in your project and you can generate code and do whatever you want to do with it. For instance, you could write a file for each session you observe that contains the Request To Code code in it. See an example and learn more…
To Install:
- Copy FiddlerRequestToCode.dll from the .zip file into your Fiddler2/Scripts folder.
- You’ll need to restart Fiddler if it’s already running.
Questions/Comments – Please post on this Fiddler Google Group Discussion.
Read the Changelog.




very cool. Thanks for doing this.
Absolutly great. Love It!
I’m a lucky guy to have found your program today. It saved me hours of work!
T H A N K Y O U!
Glad to hear it!
Great job Chad! I love it!
Great little tool, saved me a bit of typing at least!
I did see one problem, the “request.ContentLength” value was not set to the correct value. I changed the code to “request.ContentLength = postBytes.Length” and it worked fine.
Thank you *very* much for this fantastic add-on, it’s great !
Just two tiny Q’s
1) What’s the purpose of the “Usage” tickbox.
2) How can we easily use your code afterwards to autorun the code/requests ?
@Steve – I think you may be mistaken. Are you able to provide a URL to test against? In my tests the request.ContentLength is being set to the proper value if there was a POST request. The extension merely copies most of the header values that I get from Fiddler. That’s why the extension writes request.ContentLength = 508; (for example) rather than always just writing request.ContentLength = postBytes.Length;. The only problem this should cause is if you want to change the request body. In that case, you would have to update the ContentLength. I’ll make the change so that it’s always set to postBytes.Length. Again, it would be great if you could also give more detail on the case you’re talking about. Thanks.
@Salabim – The usage box generates a function that calls all of the request functions that were generated and gives you a good idea of how to use the functions. That usage box is the quickest way. You’ll want to have that option on, then copy all of the code into your Visual Studio project. If all you want is for the requests to be reissued from your code, that’s all you should need to do. If you want to actually examine the responses, you’ll need to add additional code. Hope that helps. I’ll try to add this information to the extension page so others will know. Thanks.
@Salabim – Forgot to mention that you’ll need to call the MakeRequests() function that is generated to actually have it call of generated request methods.
1) Drag and Drop your sessions into the “Code” view.
2) Ensure the “Usage” option is checked.
3) Copy all of the generated code into your Visual Studio project.
4) In your code in VS, call MakeRequests()
Will Fiddler work when testing what values are being sent to a Learning Management System (LMS) outside of our company. The hdnCompletionStatus is set to Failed until they reach the passing score of 70% in which it changes to Passed. On the LMS side once it reaches the passing score of 70% the Listerner page stops. The LMS company used the Fiddler to check what data was coming back from the CBTs which they noted is 70% even though the actual score could be 80, 90 or 100%. The same CBTs works in the UAT environment documenting the correct score that was achieved.
Questions is will Fiddle let me know what we are actually passing to the LMS which seems to be different than what the LMS is receiving or processing once they receive it. I don’t know much about a Listening page but if its stops working after it indicated that they reached the minimum passing score, how would it catch the actual end results of the missed questions.
Any help you can provide will be greatly appreciated…the CBTs in questions were built using Captivate 4.
Thanks Cathy
Hi Cathy,
This question would be better answered on the official Fiddler forums: http://groups.google.com/group/httpfiddler. This page is just about an extension I built for Fiddler.
In general, it sounds like you want to look at the web traffic. If your web pages use HTTP to send information to the LMS, you should be able to watch it with Fiddler and see the values being sent. Just give it a try or check out the Fiddler help pages to get a better idea of how to use Fiddler: http://fiddler2.com/Fiddler/help/
Thanks and good luck,
~Chad
Hi Chad,
I love this extension for fiddler, I don’t suppose I could request a feature where you can execute the code request from within fiddler itself?
Cheers,
Lewis
Lewis – thanks for your comment and question! I’ve added dynamic compilation in version 1.7.0 as you can read in the changelog.
Also, have you considered just using Fiddler’s “Request Builder” if you just need to make one-off requests and change the headers/body of the request?
Thank you, works perfectly.
Hi Chad, this is a wonderful and very useful plugin. But i have character problems on ajax post request. Dou have any exprience about this issuse?
Hi ümit! You’ll have to provide more information about the characters that you’re having trouble with. Can you post a sample here, or provide a link where I can try this myself? Thanks for the kinds words and I’m glad you like the extension. Thanks, ~Chad
Awesome Job Chad, Keep it up! It works!
Hi Chad,
I just downloaded Fiddler Request To Code 1.7.1 and noticed a couple of issues when clicking the Run (beta) button when the language is C#.
First, I receive an compilation error indicating that the source code could not be compiled because the type or namespace ‘Stream’ could not be found.
Second, if I add the statement
using System.IO;to the top of the code window, I receive a compilation error indicating that there is an invalid token ‘using’ in class, struct, or interface member declaration.Third, when the code is created, if the request being converted contains a SOAPAction in the request header, when the code is created for the line below, it creates two double-quotes around the method name in that line, as follows:
request.Headers.Add("SOAPAction", ""methodName"");. It should only have one double-quote before and after the method name value.Finally, if the request being converted contains a value of “Expect: 100-continue” in the request header, the code creates the following line, which causes an exception because the .NET Framework rejects values containing the string “100-continue” for the property being set:
request.Expect = "100-continue";Other than these issues, the extension works nicely from what I’ve seen so far. Also, I’d be happy to fix these issues and test the modifications if you’d like to send me the source code.
Keep up the good work!
Hi Michael. Thanks for the bug reports. Request To Code 1.8.0 has been published and it addresses/fixes all of the issues you mentioned.
You can read the Changelog for more information.
Thanks Chad for this great add-on. it works perfect. I’m just wondering to create a loop and delay in the code. Like for example when I drag the session to code box I get the code. now I add a loop to it and when I run it it’s fine and doesn’t get back any error but it just requests it once. even I have added loop to run it for example 4 times. I found how to add delay on running the code. I just need help to add loop to it. Thank you very much in advance.
Hi Mohammad. I can’t reproduce your problem. In fact, I can easily add loops such as:
private void MakeRequests() { HttpWebResponse response; for(int i=0; i<4; i++) { if (Request_www_fiddler2_com(out response)) { response.Close(); } } }When I run this (along with the generated "Request_www_fiddler2_com" function), I see 4 requests in the Fiddler window, just like I would expect. Can you please post the code you're trying to run, so I can further help? Thanks.