Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Gives Bad Request error or Status 400 when we delete the record using CRM Restbuilder.

(0) ShareShare
ReportReport
Posted on by 11

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));

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Gives Bad Request error or Status 400 when we delete the record using CRM Restbuilder.

    Hi,

    In that case you should debug your plugin to check the issue.

    Please mark my answer verified if i were helpful

  • Rahul Rathore Profile Picture
    11 on at
    RE: Gives Bad Request error or Status 400 when we delete the record using CRM Restbuilder.

    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.

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Gives Bad Request error or Status 400 when we delete the record using CRM Restbuilder.

    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();

    Please mark my answer verified if i were helpful

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106 Most Valuable Professional

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 95

Overall leaderboard

Product updates

Dynamics 365 release plans