我想使用webapi v9.0更新Dynamics 365 9.0中已经存在的约会的ActivityParty。我的目标是更新必需的与会者和可选的与会者字段。
我正在尝试创建一个PUT请求,如webapi文档中的使用集合值导航属性在更新时关联实体下所述。
在下面找到我正在使用的代码:
var activity = {};
var parties = [];
var requiredAttendee = {};
requiredAttendee["partyid_lead@odata.bind"] = "/leads(3fcc8c7b-e38d-e911-90f8-005056879361)";
requiredAttendee["participationtypemask"] = 5;
var optionalAttendee = {};
optionalAttendee["partyid_account@odata.bind"] = "/accounts(2e1261de-77cf-4f9b-a1bb-ff3a1f5a4add)";
optionalAttendee["participationtypemask"] = 6;
parties.push(requiredAttendee);
parties.push(optionalAttendee);
activity["value"] = parties;
var req = new XMLHttpRequest();
req.open("PUT", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/appointments(20064d15-728e-e911-90f8-005056879361)/appointment_activity_parties", true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(activity));
我希望请求成功。但是我收到一个错误请求,并显示以下错误消息:
验证输入参数时发生错误:System.InvalidCastException:无法将类型为“ System.Web.OData.Formatter.Deserialization.ODataResourceWrapper”的对象转换为类型为“ System.Web.OData.Formatter.Deserialization.ODataNestedResourceInfoWrapper”的对象。
有人知道我在做什么错吗?