Gives Bad Request error or Status 400 when we delete the record using CRM Restbuilder.
var parameters = {};
parameters.recordId = "029969d6-40f6-ea11-a815-000d3a98d1ad";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/ig1_DeleteBidSheetOrTemplate", 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) {
//Success - No Return Data - Do Something
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(parameters));
Hi,
In that case you should debug your plugin to check the issue.
We are calling the plugin using Action. the plugin returns the following error.
'ig1_bidsheetpricelistitem' entity doesn't contain attribute with Name = 'ig1_bidsheetid' and NameMapping = 'Platform'. MetadataCacheDetails: ProviderType=Dynamic, StandardCache=True, IsLoadedInStagedContext = False, Timestamp=37633870, MinActiveRowVersion=37633870, MetadataInstanceId=31980349.
Hi,
To Delete record, we don't use Post method instead we need to Delete.
Check below link.
docs.microsoft.com/.../update-delete-entities-using-web-api
DELETE [Organization URI/api/data/v9.0/accounts(00000000-0000-0000-0000-000000000001) HTTP/1.1
Content-Type: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Also, Bad request is only status returned from the server. You should use dveloper Tool (Hit F12) to check network tab for more detailed error.
Code generated from Rest Builder which is completly different that what you have shared in your post.
var req = new XMLHttpRequest(); req.open("DELETE", Xrm.Page.context.getClientUrl() "/api/data/v9.1/accounts(00000000-0000-0000-0000-000000000000)", 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) { //Success - No Return Data - Do Something } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send();
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Muhammad Shahzad Sh...
106
Most Valuable Professional
Eugen Podkorytov
95