[英]Dynamics Crm 365 webapi - publish webresource via javascript
This article shows how to publish a webresource using javascript and soap.本文展示了如何使用 javascript 和 soap 发布网络资源。
http://mileyja.blogspot.com.au/2011/05/how-to-publish-all-customizations-using.html http://mileyja.blogspot.com.au/2011/05/how-to-publish-all-customizations-using.html
is there a way to call a publish request in javascript via the web api instead?有没有办法通过 web api 在 javascript 中调用发布请求?
Yes, it's perfectly possible using the PublishAllXml or PublishXml actions.是的,完全可以使用PublishAllXml或PublishXml操作。 You can use CRMRESTBuilder to easily test these actions:
您可以使用CRMRESTBuilder轻松测试这些操作:
PublishAllXml Example PublishAllXml 示例
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();
PublishXml Example (it will publish only the account entity): PublishXml 示例(它将仅发布帐户实体):
var parameters = {};
parameters.ParameterXml = "<importexportxml><entities><entity>account</entity></entities></importexportxml>";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/PublishXml", 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(JSON.stringify(parameters));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.