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