Hello all,
trying to create a new record using JS web API , it has lookup fields. I'm passing GUID like below, but it's throwing an error "BAD REQUEST". i tried with commenting lookup fields, then it's working. Any help will be appreciated. Thank you in advance.
var entity = {};
entity.ca_agreementstartdate = new Date("02/11/2019").toISOString();
entity["ca_office@odata.bind"] = "/ca_offices(B61B0235-60AE-4EE3-BADE-21D96BB0F0B2)";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/ca_preapprovalrequests", 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));
*This post is locked for comments
I have the same question (0)

Report
All responses (
Answers (