on 03-31-2015 2:44 PM
Hi Experts,
I'm trying to do CRUD demo app with oModel,oModel.read and oModel.remove work fine,but oModel.create and oModel.update,I got the error :
system expect the element '{http://www.w3.org/2005/Atom}entry'
My js code:
oModel : null,
onInit : function() {
// Initialize the Model
this.oModel = new sap.ui.model.odata.ODataModel(
"proxy/sap/opu/odata/SAP/ZWODATA_SCNBLOG2_SRV/",
true, "USERNAME", "PASSWORD");
this.oModel.setHeaders(
{
"X-Requested-With" : "XMLHttpRequest",//JSONHttpRequest
"Content-Type" : "application/atom+xml",
"DataServiceVersion" : "2.0",
"Accept" : "application/atom+xml,application/atomsvc+xml,application/xml",
}
);
// set global models
sap.ui.getCore().setModel(this.oModel);
},
Create2 : function() {
alert("Create2");
var oEntry = {};
oEntry.Email = "hellofiori01@126.com";
oEntry.Firstname = "hello01";
oEntry.Lastname = "fiori01";
this.oModel.create('/SCNBLOG2Set',
oEntry,
null,
function(oData, oResponse){
alert("Create successful");
},
function(oError){
alert("Create failed " + oError.message);
}
);
},
I found it didn't post any data to server when operation is create or update,
Please help me on this. I am really stuck.
Thanks in Advance..
I code like this,but it doesn't work,I hope someone could help me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Felix,
That means your Payload is not correct.
You need to pass Correct Headers.
Share the payload which is sent from UI to Gateway.
For XML -> Sample
Headers :
x-csrf-token - Pass the value
Content-Type - application/atom+xml
Payload :
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<atom:content type="application/xml">
<m:properties>
<d:IvManuCompany>0100</d:IvManuCompany>
<d:RequestNo>TEST_INC</d:RequestNo>
<d:RequestItmno>0000</d:RequestItmno>
<d:FromPackage>NZ0025</d:FromPackage>
<d:ToPackage>NZ0025</d:ToPackage>
<d:Quantity>1.000</d:Quantity>
<d:BaseUnit>TON</d:BaseUnit>
</m:properties>
</atom:content>
</atom:entry>
For JSON -> Sample
Headers :
x-csrf-token - Pass the value
Content-Type - application/json
Payload :
{
"IvManuCompany":"0100",
"RequestNo":"TEST_IN1",
"RequestItmno":"0001",
"FromPackage":"NZ0025",
"ToPackage":"NZ0025",
"Quantity":"1",
"BaseUnit":"TON"
}
Please refer ->
Regards,
Ashwin
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.