Odata.Request for Multiple Entries

Feb 21, 2013 at 2:26 AM
Edited Feb 21, 2013 at 2:29 AM
hi

i have a problem, i test in rest client in firefox the post method, whit this XML works,

<?xml version="1.0" encoding="UTF-8"?>
<atom:entry
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:OrderId>1</d:OrderId>
<d:CustomerId>0100004399</d:CustomerId>
</m:properties>
</atom:content>
<atom:link
rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SOItems"
type="application/atom+xml;type=feed"
title="XXX">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:OrderId>1</d:OrderId>
<d:Material>000000000000141776</d:Material>
</m:properties>
</atom:content>
</atom:entry>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:OrderId>1</d:OrderId>
<d:Material>000000000000141773</d:Material>
</m:properties>
</atom:content>
</atom:entry>

now i try simulate process in JavaScript:

var xmlatom =
{
"OrderId": "0",
"CustomerId": "0100004399",
"SOItem":
[
{
"OrderId": "0",
"Material": "000000000000141776"
},
{
"OrderId": "0",
"Material": "000000000000141773"
}
]
};

var request = { headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token": header_xcsrf_token},
requestUri: requestURL,
method: "POST",
data: xmlatom,};


//Request de inserción
OData.request(
request,
function (data) {
//Success Callback
$("#resultsArea").text("Insertado correctamente");
},
function (err) {
//Error Callback:
alert("Error occurred " + err.message);
$("#resultsArea").text(JSON.stringify(err));
}

the problem is because the variable "xmlatom" is not being interpreted as having several entities but interprets it as if it were a single entity.

can anyone help me on how I should write the data from multiple entities for odata.request?