c# - 在线 CRM REST 服务 - 遇到问题

标签 c# rest dynamics-crm-online

这是一项简单的任务,但我浪费了不止一天的时间。这就是为什么要来找你。请帮我解决这个问题。

我的要求很简单,我有一个 ASP.NET 项目。我在在线 CRM 中有一个实体

实体名称:“员工”,字段为“姓名、年龄、性别”

我无法在我的 asp.net 项目中添加 CRM Dll。所以我必须使用 REST 服务。

  1. 我添加了服务引用 https://myoffice.crm5.dynamics.com/xrmservices/2011/organization.svc?wsdl

  2. 这是我正在使用的代码

    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 中。

有什么帮助吗?

最佳答案

这可能看起来很奇怪,但原因是服务器上的时钟和客户端上的时钟肯定不同步。

您所要做的就是检查:

  1. 客户端时钟与服务器时钟同步。
  2. 客户端和服务器都在日间保存设置上协调

问候,

凯文

来源:herehere

关于c# - 在线 CRM REST 服务 - 遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11557768/

相关文章:

c# - 这段异步代码有什么问题?

java - 从 Rest Controller 返回对象层次结构时如何使用 Spring MVC @JsonView

sql - SQL Azure 上超时已过期;无法在本地 SQL Server 上重现

c# - 返回适当的消息给主叫客户端

报告有多少潜在客户从不合格转变为合格

javascript - 如何在 Dynamics CRM 中获取处理完成按钮事件?

C# 和 mysqldump

c# - 从部署的 Web 应用程序调用时,Azure 函数应用程序不会触发

dynamics-crm-2011 - Microsoft Dynamics Crm Sdk - 此查询是否可行?

c# - 从 C# 中调用 StrFormatByteSize64 函数