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.
Thank you in advance
*This post is locked for comments
Hi Rushikesh ,
I am facing the same issue did you get the solution? If yes please help me also.
Thanks
Ankit
Yes.. I am getting 200 OK as response. but not able to see expected result
Have you tried debugging the code?
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);
}
Hi Rushikesh,
Can you please share the full code?
Also, see the link below and make sure that you are using the same code.
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");
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156