我正在研究MS Dynamics 365,我参考了Microsoft documentation。
此处,当我发布数据时,它会提供 500内部服务器错误
" GET"适用于相同的api端点。
我们是否有任何我缺少的关系参数?
发布数据
var payload = new
{
subject = "TestSubject",
statecode=2,
statuscode=3,
responsecode=1
};
答案 0 :(得分: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));