title: C# How to retrieve Dynamics Finance and Operations entity records
body: <p>I am struggling to retrieve an entity records in Microsoft ERP Dynamics Finance and Operations. I was able to get authentication access but when I use the http request it show me an error.</p>
  <p>My code:</p>
  <pre><code> string clientId = &quot;clientId&quot;;
          string clientSecret = &quot;clientSecret&quot;;
          string authority = &quot;https://login.microsoftonline.com/tenantId&quot;;
          string resourceUrl = &quot;https://trial-ub2dbh.sandbox.operations.dynamics.com/&quot;; // Org URL
  
          try
          {
              ClientCredential credentials = new ClientCredential(clientId, clientSecret);
              var authContext = new Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext(authority);
              var result = await authContext.AcquireTokenAsync(resourceUrl, credentials);
  
              HttpClient httpClient = null;
              httpClient = new HttpClient();
              httpClient.DefaultRequestHeaders.Add(&quot;OData-MaxVersion&quot;, &quot;4.0&quot;);
              httpClient.DefaultRequestHeaders.Add(&quot;OData-Version&quot;, &quot;4.0&quot;);
              httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(&quot;application/json&quot;));
              httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(&quot;Bearer&quot;, result.AccessToken);
              httpClient.BaseAddress = new Uri(&quot;https://trial-ub2dbh.sandbox.operations.dynamics.com/data/$metadata#&quot;);
  
              var response_Contacts = httpClient.GetAsync(&quot;PartyContacts&quot;).Result;
  
          }
          catch(Exception ex)
          {
              return ex.ToString();
          }
  </code></pre>
  <p>The error is :</p>
  <blockquote>
  <p>bad request</p>
  </blockquote>
  <p>How can I make this retrieve?</p>