title: How can I trace oData request from a .Net DataServiceContext over SSL?
body: <p>I am developing a .Net client to retrieve data from an oData service. My client uses a System.Data.Services.Client.DataServiceContext. </p>
  
  <p>I would like to see the actual oData requests sent out to the server. The server uses an SSL connection and requests to the server cannot easily be sniffed. I tried to do this with <a href="http://portswigger.net/burp/" rel="nofollow">Burp</a>. I added a SendingRequest EventHandler and set the Request.Proxy property. But this gives an exception: </p>
  
  <blockquote>
    <p><em>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</em></p>
  </blockquote>
  
  <p><a href="http://www.wireshark.org/" rel="nofollow">Wireshark</a> just shows the encrypted data.</p>
  
  <p>Alternatively, I could contact the oData provider for server logs, but that would take some time. I am looking for a instantaneous trace.</p>
  
  <hr>
  
  <p>Here is a sample client, that uses the Microsoft Northwind oData service.</p>
  
  <ol>
  <li>Create a Class Library;</li>
  <li>Add a Service Reference to <a href="http://services.odata.org/V3/Northwind/Northwind.svc/" rel="nofollow">Northwind</a>;</li>
  <li>Create a class oDataClient; </li>
  <li>Add a method <code>Customers()</code>;</li>
  <li>Create a Test project;</li>
  <li>Create in it a unit test for <code>Customers()</code>;</li>
  <li>Run the test.</li>
  </ol>
  
  <p>Method:</p>
  
  <pre><code>public class oDataClient
  {
      public void Customers()
      {
          {
              var context = new Northwind.NorthwindEntities(new System.Uri("http://services.odata.org/V3/Northwind/Northwind.svc/"));
  
              var customers = from c in context.Customers 
                              where c.CompanyName.StartsWith("A")
                              select c;
  
              int count = customers.Count();
          }
      }
  }
  </code></pre>
  
  <p>Test:</p>
  
  <pre><code>[TestMethod()]
  public void CustomersTest()
  {
      oDataClient target = new oDataClient();
      target.Customers();
  }
  </code></pre>