这是一项简单的任务,但我浪费了不止一天的时间。这就是为什么要来找你。请帮我解决这个问题。
我的要求很简单,我有一个 ASP.NET 项目。我在在线 CRM 中有一个实体
实体名称:“员工”,字段为“姓名、年龄、性别”
我无法在我的 asp.net 项目中添加 CRM Dll。所以我必须使用 REST 服务。
我添加了服务引用 https://myoffice.crm5.dynamics.com/xrmservices/2011/organization.svc?wsdl
这是我正在使用的代码
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)
{
}
运行 orgClient.Create(myContact) 时出现“验证消息的安全性时发生错误”错误。
不管我到目前为止做了什么。这是我的要求,使用 REST 服务非常简单地将我的自定义实体条目添加到在线 CRM 中。我将在名为 http://xyz.com 的单独域中运行我的 Web 应用程序.从这里,我需要将条目添加到在线 CRM 中。
有什么帮助吗?
最佳答案
这可能看起来很奇怪,但原因是服务器上的时钟和客户端上的时钟肯定不同步。
您所要做的就是检查:
- 客户端时钟与服务器时钟同步。
- 客户端和服务器都在日间保存设置上协调
问候,
凯文
关于c# - 在线 CRM REST 服务 - 遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11557768/