MS Dynamics 活动响应 POST:500 内部服务器错误

MS Dynamics Campaign Response POST : 500 Internal Server Error

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

这里当我post它给出的数据500 Internal Server Error

"GET" 适用于相同的 api 端点。

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

Post数据

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

你不见了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));