Skip to main content

Notifications

Announcements

No record found.

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
    Bipin D365 28,961 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
    Rahul Rathore 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
    Bipin D365 28,961 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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans