public static void DataverseConnector()
{
try
{
string conn = @"AuthType=OAuth;Username=user@org.onmicrosoft.com;Password=password;Url=https://orgapp.crm.dynamics.com;TokenCacheStorePath=c:\MyTokenCache2;LoginPrompt=Auto";
using (ServiceClient serviceClient = new ServiceClient(conn))
{
if (serviceClient.IsReady)
{
var columnSet = new ColumnSet("name","numberofemployees");
var accountrecord= serviceClient.Retrieve("account", new Guid("a17f700a-6d37-ee11-bdf4-000d3a0aab51"),columnSet);
Console.WriteLine(accountrecord.Id);
Console.WriteLine(accountrecord["name"]);
Console.WriteLine(accountrecord["numberofemployees"]);
}
else
{
Console.WriteLine("A web service connection was not established.");
}
}
// Pause the console so it does not close.
Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
}
No comments:
Post a Comment