- I have an entity and there is a web resource inside, when i click the button in this web resource and it will trigger a javascript script to update this entity.
- And a plugin, this plugin will be triggered when specified attribute is changed in the entity.
But when I want to start profiling to debug this plugin using Plugin Registration Tool, this js script update will hit an unexpected return value, this.status is 400. However when I disable this plugin debugging, return value of this js update is 204, it is correct.
I don't understand why this problem is happening, anybody know why?
The following is a part of script:
var req = new XMLHttpRequest();
req.open("PATCH", window.parent.Xrm.Page.context.getClientUrl() + "/api/data/v8.0/" + entityName + "s(" + entityId + ")", false);
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) {
window.parent.Xrm.Utility.openEntityForm(entityName, entityId);
}
else {
alert("System Exception!");
}
}
};
req.send(JSON.stringify(entity));