Search code examples
powershellasp.net-web-apivisual-studio-2013

Fiddler not intercepting PowerShell web requests


I'm trying to use Fiddler to help someone troubleshoot an issue with Invoke-RestMethod calls to an ASP.NET WebAPI. Unfortunately, when I call Invoke-RestMethod in PowerShell, Fiddler is not intercepting the HTTP communications.

When I use Internet Explorer to browse the root of the ASP.NET website, which is part of the same application, Fiddler intercepts traffic as expected.

Can anyone explain why Fiddler is not capturing HTTP traffic through PowerShell, and how to resolve this?


Solution

  • Fiddler actually works via a proxy, and automatically sets proxy settings in IE when running. You can check this by launching fiddler and then checking "Lan Settings" under Internet Options > Connection.

    Invoke-RestMethod has a -Proxy parameter you can use to point to Fiddler's proxy. I think the default is 127.0.0.1:8888 :

    Invoke-RestMethod -Proxy 'http://127.0.0.1:8888' ....

    Edit: Adding screenshot to confirm the answer above.

    Fiddler Options