Fiddler not capturing HTTP requests from Java Application

Andrew picture Andrew · Mar 8, 2012 · Viewed 22.3k times · Source

I am currently writing a java application that uses HTTP POST to upload a csv file and a few other parameters to a server. The server keeps returning 500 errors to my application and I would like to view the HTTP request in Fiddler so I can see the POST request.
When I run Fiddler it will not capture any HTTP traffic from the Java application. I have written a GET request that works, so I know I can communicate with the server, however no traffic is shown through Fiddler.

Answer

Robert picture Robert · Mar 8, 2012

You can simply set Fiddler as HTTP proxy for your application by setting the properties

http.proxyHost to localhost and http.proxyPort to 8888 for HTTP traffic and https.proxyHost / https.proxyPort for HTTPS traffic. For HTTPS traffic you also have to add the Fiddler root certificate (exportable in options dialog) as trusted certificate to your application.

You can do so by adding the following lines at the beginning of your code

System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8888");

or set them via command line when starting the Java-VM:

java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 ...