cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

SAPUI5 SDK - Demo Kit

I code like this,but it doesn't work,I hope someone could help me.

AshwinDutt
Active Contributor
0 Kudos

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

Former Member
0 Kudos

yes, you are right,thank for your reply,I think I know where I'm wrong,

I should use "JSONHttpRequest" instead of "application/atom+xml"

thank you very much.

Answers (0)