Hi, I am looking to connect with D365 online through .net console app with the below code, and I got the below error, it looks like I have to create application user and get the application id and secret ? can I connect with my logins ? Please advise.
Error message: "An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."
IOrganizationService organizationService = null;
try
{
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "username";
clientCredentials.UserName.Password = "password";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri("https://recotest2.api.crm3.dynamics.com/XRMServices/2011/Organization.svc"),
null, clientCredentials, null);
if (organizationService != null)
{
Guid userid = ((WhoAmIResponse)organizationService.Execute(new WhoAmIRequest())).UserId;
if (userid != Guid.Empty)
{
Console.WriteLine("Connection Successful!...");
}
}
else
{
Console.WriteLine("Failed to Established Connection!!!");
}
}
catch (Exception ex)
{
Console.WriteLine("Exception caught - " ex.Message);
}
Console.ReadKey();