web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM WebApi batch request

(0) ShareShare
ReportReport
Posted on by 5,241

With this guide: https://msdn.microsoft.com/en-us/library/mt607719.aspx, I'm trying to create a batch request to delete all quotedetails on a quote.

I'm using jquery's ajax to do the request:

$.ajax(
{
    method: 'POST',
    url: 'http://crm/api/data/v8.0/$batch',
    headers: {
        'Content-Type': 'multipart/mixed;boundary=batch_' + batchId,
        'Accept': 'application/json'
    },
    data: payload
});


And this is the payload:

–batch_SuL11egVC7
Content-Type:multipart/mixed;boundary=changeset_Sj74vxbGYr

–changeset_Sj74vxbGYr
Content-Type:application/http
Content-Transfer-Encoding:binary
Content-ID:1

DELETE crm/.../quotedetails(cc9b9ba8-4570-e611-80ba-0050568a6c2d) HTTP/1.1
Content-Type: application/json;type=entry
–changeset_Sj74vxbGYr
Content-Type:application/http
Content-Transfer-Encoding:binary
Content-ID:2

DELETE crm/.../quotedetails(cd9b9ba8-4570-e611-80ba-0050568a6c2d) HTTP/1.1
Content-Type: application/json;type=entry
–changeset_Sj74vxbGYr--

-batch_SuL11egVC7--


I'm not getting an error, but the quotedetails aren't deleted.

This is the response:

--batchresponse_a3304387-0e91-4097-b9f8-a207da3aa845--


Any clues on what I'm doing wrong?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    JohnAnonymous Profile Picture
    5,241 on at
    RE: CRM WebApi batch request

    After some extensive testing I figured it out. A few things were wrong with this example:

    1. -batch and -changeset should be with two dashes: --batch --changeset
    2. When deleting records, you stil need to send an empty object

    I've done my testing with Postman to quickly try out new alterations. This is my working example:

    --batch_AAA123
    Content-Type: multipart/mixed;boundary=changeset_BBB456
    
    --changeset_BBB456
    Content-Type: application/http
    Content-Transfer-Encoding:binary
    Content-ID: 1
    
    DELETE tenanturl/.../quotedetails(a223ad55-457b-e611-80bb-0050568a6c2d) HTTP/1.1
    Content-Type: application/json;type=entry
    
    {}
    --changeset_BBB456
    Content-Type: application/http
    Content-Transfer-Encoding:binary
    Content-ID: 2
    
    DELETE tenanturl/.../quotedetails(a323ad55-457b-e611-80bb-0050568a6c2d) HTTP/1.1
    Content-Type: application/json;type=entry
    
    {}
    --changeset_BBB456--
    --batch_AAA123--


      I hope this helps somebody in the future.

  • Suggested answer
    Tandhika Profile Picture
    10 on at
    RE: CRM WebApi batch request

    You don't need to provide an empty object. The problem is the Content-Type header. You should not set it. And add an empty line before the change set separator.

    So, this should work:

    --batch_AAA123
    Content-Type: multipart/mixed;boundary=changeset_BBB456
    
    --changeset_BBB456
    Content-Type: application/http
    Content-Transfer-Encoding:binary
    Content-ID: 1
    
    DELETE tenanturl/.../quotedetails(a223ad55-457b-e611-80bb-0050568a6c2d) HTTP/1.1
    
    --changeset_BBB456
    Content-Type: application/http
    Content-Transfer-Encoding:binary
    Content-ID: 2
    
    DELETE tenanturl/.../quotedetails(a323ad55-457b-e611-80bb-0050568a6c2d) HTTP/1.1
    
    --changeset_BBB456--
    --batch_AAA123--

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans