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.
My code:
 string clientId = "clientId";
        string clientSecret = "clientSecret";
        string authority = "https://login.microsoftonline.com/tenantId";
        string resourceUrl = "https://trial-ub2dbh.sandbox.operations.dynamics.com/"; // 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("OData-MaxVersion", "4.0");
            httpClient.DefaultRequestHeaders.Add("OData-Version", "4.0");
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken);
            httpClient.BaseAddress = new Uri("https://trial-ub2dbh.sandbox.operations.dynamics.com/data/$metadata#");
            var response_Contacts = httpClient.GetAsync("PartyContacts").Result;
        }
        catch(Exception ex)
        {
            return ex.ToString();
        }
The error is :
bad request
How can I make this retrieve?
 
     
    