3

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.

  1. I have added service reference https://myoffice.crm5.dynamics.com/xrmservices/2011/organization.svc?wsdl

  2. 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?

2 Answers2

1

It could seems strange but the reason is that the clock on the server and on the client are certainly not synchronized.

All you have to do is check that :

  1. The client clock is synched with the server clock.
  2. Both client and server are coordinated on the day time saving settings

Regards,

Kévin

Sources : here and here

1

The REST service is not exposed for external applications, it is for internal applications only. You may be able to get around this in an on premise deployment but in CRM Online there is no workaround that I am aware of. You are much better off if you add the CRM assemblies and do this in C#. Also, with the REST service you are severely limited to CRUD operations and you can't perform things like assign or change state. In my opinion the SOAP service is superior, but it still cannot be called from an external web application.

See the note that reads the following at this link - Data Access Using JavaScript

Note

It is not possible for an external application to use these web services because authentication is provided by Microsoft Dynamics CRM.

Community
  • 1
  • 1
cchamberlain
  • 17,444
  • 7
  • 59
  • 72