The post Dynamics CRM V9 / D365 connection Error Console or Custom Web Application appeared first on Microsoft Dynamics 365 Blog.
]]>Message : “One or more errors occurred.”
Source : “mscorlib”
Code Snippet :
//Create an HTTP client to send a request message to the CRM Web service.
using (HttpClient httpClient = new HttpClient(messageHandler))
{
//Specify the Web API address of the service and the period of time each request
// has to execute.
httpClient.BaseAddress = new Uri(serviceUrl);
httpClient.Timeout = new TimeSpan(0, 2, 0); //2 minutes
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
//Send the WhoAmI request to the Web API using a GET request.
var response = httpClient.GetAsync(“api/data/v9.0/WhoAmI”,
HttpCompletionOption.ResponseHeadersRead).Result;
if (response.IsSuccessStatusCode)
{
//Get the response content and parse it.
JObject body = JObject.Parse(response.Content.ReadAsStringAsync().Result);
Guid userId = (Guid)body[“UserId”];
Console.WriteLine(“Your system user ID is: {0}”, userId);
}
else
{
Console.WriteLine(“The request failed with a status of ‘{0}'”,
response.ReasonPhrase);
}
}
Happy Coding
SOURCE : https://community.dynamics.com
The post Dynamics CRM V9 / D365 connection Error Console or Custom Web Application appeared first on Microsoft Dynamics 365 Blog.
]]>