I would like to update the ActivityParty of an already existing appointment in dynamics 365 9.0 using the webapi v9.0. My goal is to update the required attendees and the optional attendees field.
I am trying to create a PUT request as described in the documentation of the webapi under Associate entities on update using collection-valued navigation property.
docs.microsoft.com/.../associate-disassociate-entities-using-web-api
Below you find the code i am using:
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));
I would expect that the request is successful. However i get a Bad Request with the following error message:
An error occurred while validating input parameters: System.InvalidCastException: Unable to cast object of type 'System.Web.OData.Formatter.Deserialization.ODataResourceWrapper' to type 'System.Web.OData.Formatter.Deserialization.ODataNestedResourceInfoWrapper'.
Does anyone have an idea what I am doing wrong?
*This post is locked for comments
I have the same question (0)