title: Connect to Microsoft Dynamics 365/2016 Web-API
body: <p>I'm trying to execute the following API Call</p>
  
  <pre><code>RetrieveRecordChangeHistoryRequest
  </code></pre>
  
  <p>I'm trying to follow <a href="https://msdn.microsoft.com/en-us/library/mt770386.aspx" rel="nofollow noreferrer">this steps</a>, but I can't replicate the code I get a bunch of errors.</p>
  
  <p>I have installed Dynamics 365 HelperCode successfully but starting managing the code I don't get why is not working. (I have 0 experience on C#)</p>
  
  <pre><code>using Microsoft.Crm.Sdk.Samples.HelperCode;
  using Newtonsoft.Json;
  using Newtonsoft.Json.Linq;
  using System.Net.Http;
  using System.Net.Http.Headers;
  
  private HttpClient httpClient;
  
  
  private void ConnectToCRM(String[] cmdargs)
  {
      Configuration config = null;
      if (cmdargs.Length &gt; 0)
          config = new FileConfiguration(cmdargs[0]);
      else
          config = new FileConfiguration(null);
      Authentication auth = new Authentication(config);
      httpClient = new HttpClient(auth.ClientHandler, true);
      httpClient.BaseAddress = new Uri(config.ServiceUrl + "api/data/v8.1/");
      httpClient.Timeout = new TimeSpan(0, 2, 0);
      httpClient.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
      httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0");
      httpClient.DefaultRequestHeaders.Accept.Add(
          new MediaTypeWithQualityHeaderValue("application/json"));
  }
  
  
  
  Program app = new Program();
  try
  {
      String[] arguments = Environment.GetCommandLineArgs();
  app.ConnectToCRM(arguments);
  }
  catch (System.Exception ex)
  { ; }
  finally
  {
      if (app.httpClient != null)
      { app.httpClient.Dispose(); }
  }
  
  
  private static void DisplayException(Exception ex)
  {
      Console.WriteLine("The application terminated with an error.");
      Console.WriteLine(ex.Message);
      while (ex.InnerException != null)
      {
          Console.WriteLine("\t* {0}", ex.InnerException.Message);
          ex = ex.InnerException;
      }
  }
  </code></pre>
  
  <p><strong>The errors</strong> </p>
  
  <p><img src="https://gdurl.com/Rab0" alt="1"></p>
  
  <p><img src="https://gdurl.com/sSFF" alt="2"></p>
  
  <p><img src="https://gdurl.com/vTWv" alt="3"></p>
  
  <p><img src="https://gdurl.com/9Z3W" alt="4"></p>