本文介绍如何使用javascript和soap发布webresource。
http://mileyja.blogspot.com.au/2011/05/how-to-publish-all-customizations-using.html
有没有办法通过web api在javascript中调用发布请求?
答案 0 :(得分:3)
是的,使用PublishAllXml或PublishXml操作完全可以。您可以使用CRMRESTBuilder轻松测试这些操作:
PublishAllXml示例
namespace myproject
PublishXml示例(它只会发布帐户实体):
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/PublishAllXml", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//Success - No Return Data - Do Something
alert("it worked!");
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();