Hi
I am getting a bad request when using the below code to send an update to a custom entity. The field is a lookup to the same entity as a reference to another instance of the entity. I have obfuscated some of the field names to protect sensitive data. Anyone have any ideas what's going on?
var target = guidoftarget;
var entity = {};
entity["mergedto@odata.bind"] = "/new_salescontracts(" + target + ")";
var req = new XMLHttpRequest();
req.open("PATCH", encodeURI(Xrm.Page.context.getClientUrl() + "/api/data/v8.1/new_salescontracts(" + guidofrecordtobeupdated + ")"), 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 || this.status == 1223) {
console.log("Success");
}
else {
alert(this.statusText);
}
}
};
req.send(JSON.stringify(entity));
*This post is locked for comments
I have the same question (0)