1

我正在研究 MS Dynamics 365,我参考了Microsoft 文档

在这里,当我发布数据时,它会给出500 Internal Server Error

“GET”适用于相同的 api 端点。

我们是否有任何我遗漏的关系参数?

发布数据

 var payload = new
        {
            subject = "TestSubject",
            statecode=2,
            statuscode=3,
            responsecode=1               
        };            
4

1 回答 1

2

你不见了regardingobjectid

我建议您使用CRM REST Builder,这将帮助您在 CRM 中生成请求、修改和测试。这将显示以红色突出显示的所有必需属性。

var entity = {};
entity.subject = "test";
entity["regardingobjectid_campaign@odata.bind"] = "/campaigns(9CFBD4BD-CD4F-E811-A95A-000D3A1A9407)";
entity.responsecode = 3;

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/campaignresponses", 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) {
            var uri = this.getResponseHeader("OData-EntityId");
            var regExp = /\(([^)]+)\)/;
            var matches = regExp.exec(uri);
            var newEntityId = matches[1];
        } else {
            Xrm.Utility.alertDialog(this.statusText);
        }
    }
};
req.send(JSON.stringify(entity));

在此处输入图像描述

于 2018-05-04T19:11:59.150 回答