Dynamics Crm 365 webapi - 通过javascript发布webresource

时间:2017-02-14 04:54:53

标签: javascript dynamics-crm crm microsoft-dynamics dynamics-crm-webapi

本文介绍如何使用javascript和soap发布webresource。

http://mileyja.blogspot.com.au/2011/05/how-to-publish-all-customizations-using.html

有没有办法通过web api在javascript中调用发布请求?

1 个答案:

答案 0 :(得分:3)

是的,使用PublishAllXmlPublishXml操作完全可以。您可以使用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();