Search code examples
c#httpsodatadynamics-crmfiddler

How to view traffic from localhost to CRM?


We are using OData Web API CRM 2016 endpoint.

I am creating a request that flows from postman, to a localhost microservice, and then to CRM:

Postman--->localhost microservice--->CRM

I am able to view the traffic from the first segment (Postman-->LocalHost); however, the fiddler trace shows nothing going from the LocalHost-->CRM.

Fiddler shows the following data for the request from Postman-->LocalHost:

POST https://localhost:19081/..../API/leads HTTP/1.1
Host: localhost:19081
Connection: keep-alive
Content-Length: 84
Cache-Control: no-cache
Origin: chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo
MSCRMCallerID: D994D6FF-5531-E711-9422-00155DC0D345
X-Postman-Interceptor-Id: 84840bba-bc4b-9b06-d3ab-e264045e8918
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
Content-Type: application/json; charset=UTF-8
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
Cookie: ai_user=Ka2Xn|2017-05-25T17:30:57.941Z

{
    "subject": "created by mscrmcaller user2: d994d6ff-5531-e711-9422-00155dc0d345"
}

However, nothing is intercepted from LocalHost-->CRM !

Please note that both routes are HTTPS.

When bypassing localhost, then the traffic is visible!

The request is created like so:

//Create payload for request
var content = new StringContent(lead.ToString(), Encoding.UTF8, "application/json");
//Create POST request with data from above
var request = RequestCreator.Create(uri, validHeaders, HttpMethod.Post, content);
//Issue request
var postResponse = Client.Instance.SendAsync(request).Result;

What are we doing wrong?


Solution

  • Fiddler doesn't track server-to-server traffic. You need to configure your "localhost microservice" to go via fiddler proxy (by default 127.0.0.1:8888) instead. If your "localhost microservice" is .NET (seems like it) you can add

    <system.net>
      <defaultProxy>
        <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
      </defaultProxy>
    </system.net>
    

    To either your web.config (will use fiddler as proxy just for your service) or machine.config (will use fiddler proxy for any .NET app).

    Machine configs are here:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
    c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
    

    Reference: http://docs.telerik.com/fiddler/Configure-Fiddler/Tasks/ConfigureDotNETApp

    Since your connection is over HTTPS you also need to configure fiddler to decrypt HTTPS traffic (Tools->Options->HTTPS->Decrypt HTTPS traffic).

    EDIT

    This suggestion assumes you'll run fiddler on the same machine as your "localhost microservice" machine, but you can run fiddler pretty much anywhere as long as port 8888 it is reachable from your "localhost microservice" machine and fiddler machine can make http request to final destination (CRM machine in your case). If you want to run fiddler elsewhere, simply configure proxyaddress to different ip like http://10.0.0.1:8888 for example. In that case you also need to configure fiddler to allow remote incoming traffic (Tools->Options->Connections->Allow remote computers to connect)