使用AJAX jQuery登录后检索Dynamics CRM中的记录 [英] Retrieving Records in Dynamics CRM after Logging in using AJAX jQuery
本文介绍了使用AJAX jQuery登录后检索Dynamics CRM中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
登录后,我可以成功地在ORGANIZATION_URL/XRMServices/2011/OrganizationData.svc/AccountSet?$select=AccountNumber
上访问XRMServices并在浏览器中检索客户帐号.但是,如果使用AJAX,则有一个身份验证服务将阻止此操作.我的代码如下
I can successfully reach XRMServices on ORGANIZATION_URL/XRMServices/2011/OrganizationData.svc/AccountSet?$select=AccountNumber
and retrieve customer account number on a browser after logging in. However, there is an authentication service blocking this if I use AJAX. My code is as below
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: ORGANIZATION_URL+ "/XRMServices/2011/OrganizationData.svc/AccountSet?$select=AccountNumber,Telephone1,Telephone2,new_CustomerDiscGroup,EMailAddress1,EMailAddress2,EMailAddress3",
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
console.log(XMLHttpRequest);
},
complete: function (XmlHttpRequest) {
console.log(XMLHttpRequest);
},
success: function (data, textStatus, XmlHttpRequest) {
console.log(data);
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
console.log(textStatus);
}
});
我想念什么?
推荐答案
经历了巨大的痛苦之后,这是使用jQuery登录Dynamics CRM的答案
After a huge pain, here is the answer to logging in to Dynamics CRM using jQuery
$.ajax({
url : 'https://<Your Authentication URL for CRM>/adfs/ls',
data : {
UserName : '<username>',
Password : '<password>',
wa : 'wsignin1.0',
wauth : 'urn:federation:authentication:windows',
wtrealm : '<CRM Location>',
wct : 'YYYY-MM-DDTHH:MM:SSZ'
},
headers : {
Accept: 'image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap,application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*','Content-Type': 'application/x-www-form-urlencoded','Access-Control-Allow-Origin' : '*'
},
crossDomain: true,
dataType: 'jsonp',
beforeSend : function(xhr){
console.log(xhr);
},
complete : function(xhr){
console.log(xhr);
},
success : function(xhr){
console.log(xhr);
},
error : function(xhr){
console.log(xhr);
}
});
希望能帮助到某人
这篇关于使用AJAX jQuery登录后检索Dynamics CRM中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文