This is a simple task, but i am wasting more than a day. Thats why coming to you. Please help me to get out of the issue.
My requirement is very simple, i have an ASP.NET project. And i have an Entity in Online CRM
Entity Name: "Employee" and Fields are "Name, Age, Gender"
I cann't add CRM Dlls in my asp.net project. So i must use REST Service.
I have added service reference https://myoffice.crm5.dynamics.com/xrmservices/2011/organization.svc?wsdl
This is the code i am using
OrganizationServiceClient orgClient = new OrganizationServiceClient();
orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("admin@something.com", "mypassword");
Entity myContact = new Entity();
myContact.LogicalName = "Employee"; //Is it right? i must provide it here right.
ConsoleApplication1.ServiceReference2.AttributeCollection myAttColl = new ConsoleApplication1.ServiceReference2.AttributeCollection();
myAttColl.Add(new KeyValuePair<string, object>("Name","Emp1"));
myAttColl.Add(new KeyValuePair<string, object>("Age", "26"));
myAttColl.Add(new KeyValuePair<string, object>("Gender", "Male"));
myContact.Attributes = myAttColl;
try
{
orgClient.Create(myContact);
}
catch (Exception ex)
{
}
I am getting "An error occurred when verifying security for the message" error when it run orgClient.Create(myContact).
No matter what i did so far. This is my requirement, a very simple adding entry to my custom entity into Online CRM using REST Service. I am going to run my webapplication in a separate domain called http://xyz.com. From here, i need to add the entries into Online CRM.
Any help?