Skip to Content
0
Former Member
Mar 31, 2015 at 01:44 PM

oModel.create & oModel.update ERROR:system expect the element '{http://www.w3.org/2005/Atom}entry'

302 Views

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..

Attachments

1.jpg (544.3 kB)