I am using the Microsoft CRM online and trying to create the Contact Entity and it throwing Authenticon endpoint user name not found exception. Could you please help me out how to resolve this? I have seen lot of forums but didn't found the solution.
Could you please help me out how to resolve this ?
OrganizationServiceProxyserviceProxy;
ClientCredentialsdeviceCredentials = null;
ClientCredentialsclientCredentials = null;
GuidcontactId = Guid.Empty;
//Organization URL
UriOrganizationUri = newUri("Entered Organization endpoint");
//Discovery URL
UriHomeRealmUri = newUri("Entered Discovery address");
//Setting Client Credentials
clientCredentials = GetCredentials("Entered the User Name","Entered my Password");
//Get the Device Id and Password
deviceCredentials =this.GetDeviceCredentials();
clientCredentials.Windows.ClientCredential =CredentialCache.DefaultNetworkCredentials;
//Using Organization Service Proxy to instantiate the CRM Web Service
using(serviceProxy = newOrganizationServiceProxy(OrganizationUri, HomeRealmUri, clientCredentials, deviceCredentials))
{
// This statement is required to enable early-bound type support.
serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(newProxyTypesBehavior());
IOrganizationServiceservice = (IOrganizationService)serviceProxy;
//Define Entity Object
Entitycontact = newEntity("contact");
//Specify the attributes
contact.Attributes["lastname"] = txtFName.Text;
//Execute the service
contactId = service.Create(contact);
//Confirmation Message
message = "Contact Created with LastName:-"+ txtFName.Text +" Guid is"+ contactId.ToString();
---------------------------------------------------------
protectedvirtualClientCredentialsGetCredentials(stringusername,stringpassword)
{
ClientCredentialscredentials = newClientCredentials();
credentials.UserName.UserName = username;
credentials.UserName.Password = password;
returncredentials;
}
protectedvirtualClientCredentialsGetDeviceCredentials()
{
returnMicrosoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
}