Difficulty connecting to Dynamics 365 Financials Web API RRS feed

  • Question

  • I am new to the Dynamics Environment and eventually want to save data from the "Contact Us" Form of a website to the Contact entity in Dynamics.  I am using Microsoft.CrmSdk.WebApi.Samples.HelperCode from NuGet and it is hanging in the Authentication Class at DiscoverAuthority().  It just sits there and fails to come back with an error code or anything.  So I have bypassed it and have set the Uri manually to "https://[mydomain].financials.dynamics.com/api/data/v8.2/". 

    For now, I am just trying to connect and return a list of the Contacts in Dynamics and get this error: There was an error deserializing the object of type Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse. Encountered unexpected character '<'.

    This will also be done via javascript.  I think everything is setup correctly, but not sure at this point.  Any help is appreciated.

                    string crmURL = "https://[domain].financials.dynamics.com/api/data/v8.2/";
                    SecureString sec = new SecureString();
                    string pwd = "*******"; 
                    pwd.ToCharArray().ToList().ForEach(c => sec.AppendChar(c));
                    Microsoft.Crm.Sdk.Samples.HelperCode.Configuration config = new Microsoft.Crm.Sdk.Samples.HelperCode.Configuration();
                    config.ServiceUrl = crmURL;
                    config.Domain = "zbestdata.com";
                    config.Username = "*******"; ; //???NOT an Email???
                    config.Password = sec;
                    config.ClientId = "*******";         
                    Authentication auth = new Authentication(config);
                    HttpClient httpClient = new HttpClient(auth.ClientHandler, true);
                    httpClient.BaseAddress = new Uri(config.ServiceUrl);
                    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"));
                    string queryOptions = "contacts?$select=fullname";
                    HttpResponseMessage response = await httpClient.GetAsync(crmURL + queryOptions); //  **Not sure this is right url
                    JObject contacts = JsonConvert.DeserializeObject<JObject>(await response.Content.ReadAsStringAsync());

    • Edited by zBestData Wednesday, December 7, 2016 3:41 PM
    Wednesday, December 7, 2016 3:36 PM