当我尝试使用控制台应用执行CRM CRUD操作时,我会收到以下错误:
System.ServiceModel.Security.MessagesEcurityException Hresult = 0x80131501 消息=从另一方收到了无抵押或不正确的固定错误。有关故障代码和详细信息,请参见内部故障分解。 来源= mscorlib
class Program
{
static void Main(string[] args)
{
IOrganizationService _serviceProxy = crmConnection();
Entity con = new Entity("contact");
con["lastname"] = "test";
_serviceProxy.Create(con);
}
private static IOrganizationService crmConnection()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Uri oUri = new Uri("https://XXXXXXXX.api.crm.dynamics.com/XRMServices/2011/Organization.svc");
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "XXXXXXXXXXXX";
clientCredentials.UserName.Password = "XXXXXXXXXXXXXXXXXX";
OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(oUri, null,clientCredentials,null);
_serviceProxy.Timeout = new TimeSpan(0, 10, 0);
return _serviceProxy;
}
}
预先感谢。
从另一方收到了无抵押或不正确的固定错误
尝试将连接字符串与xrmtooling使用以这种方式避免直接致电到组织。SVC并将重定向处理为SDK
var conn = new CrmServiceClient("AuthType=Office365;Username=xxx@xxx.com; Password=yyyyyy;Url=https://xxxx.crm.dynamics.com;RequireNewInstance=True");
IOrganizationService _orgService = conn.OrganizationWebProxyClient ?? (IOrganizationService)conn.OrganizationServiceProxy;
return _orgService;
如果继续进行错误可能与您的PC时间和Dynamics Server之间的差异有关 -4分钟,然后重试。
希望它有帮助