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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Create Record using Batch Web API

(0) ShareShare
ReportReport
Posted on by 285

Hi All,

I am trying to create multiple  Records in custom entity using Batch Execute. My Batch is executing but records are not created in entity. I am not able to identify what wrong I am doing.

2114378.Capture.PNG

Thank you in advance

*This post is locked for comments

I have the same question (0)
  • Rushikesh Bhujbal Profile Picture
    285 on at

    I have used this headers

    req.open("POST", window.parent.Xrm.Page.context.getClientUrl() + "/api/data/v8.1/$batch", true);

       req.setRequestHeader("Content-Type", 'multipart/mixed;boundary=--batch_123456');

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("OData-MaxVersion", "4.0");

       req.setRequestHeader("OData-Version", "4.0");

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Rushikesh,

    Can you please share the full code?

    Also, see the link below and make sure that you are using the same code.

    community.dynamics.com/.../web-api-bulk-operations

  • Rushikesh Bhujbal Profile Picture
    285 on at

    function testBatch() {

       var data = [];

       data.push('--batch_123456');

       data.push('Content-Type: multipart/mixed;boundary=changeset_BBB456');

       data.push('');

       data.push('--changeset_BBB456');

       data.push('Content-Type:application/http');

       data.push('Content-Transfer-Encoding:binary');

       data.push('Content-ID:1');

       data.push('');

       data.push('POST ' + window.parent.Xrm.Page.context.getClientUrl() + '/api/data/v8.2/rnct_dailyfooddeliveries HTTP/1.1');

       data.push('Content-Type:application/json;type=entry');

       data.push('');

       data.push('{"rnct_name":"199"}');

       data.push('--changeset_BBB456');

       //data.push('--batch_123456');

       data.push('Content-Type:application/http');

       data.push('Content-Transfer-Encoding:binary');

       data.push('Content-ID:2');

       data.push('');

       data.push('POST ' + window.parent.Xrm.Page.context.getClientUrl() + '/api/data/v8.2/rnct_dailyfooddeliveries HTTP/1.1');

       data.push('Content-Type:application/json;type=entry');

       data.push('');

       data.push('{"rnct_name":"199"}');

       data.push('--changeset_BBB456--');

       data.push('--batch_123456--');

       var payload = data.join('\r\n');

       var req = new XMLHttpRequest();

       req.open("POST", window.parent.Xrm.Page.context.getClientUrl() + "/api/data/v8.2/$batch", true);

       req.setRequestHeader("Content-Type", 'multipart/mixed;boundary=--batch_123456');

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("OData-MaxVersion", "4.0");

       req.setRequestHeader("OData-Version", "4.0");

       //  req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");

       req.onreadystatechange = function () {

           if (this.readyState === 4) {

               console.log(this.responseText);

           }

       }

       req.send(payload);

    }

  • Nithya Gopinath Profile Picture
    17,078 on at

    Have you tried debugging the code?

  • Rushikesh Bhujbal Profile Picture
    285 on at

    Yes.. I am getting 200 OK as response. but not able to see expected result

  • Community Member Profile Picture
    on at

    Hi Rushikesh ,

    I am facing the same issue did you get the solution? If yes please help me also.

    Thanks

    Ankit

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans