cancel
Showing results for 
Search instead for 
Did you mean: 

oModel.update() - Error while parsing xml-stream

Former Member
0 Kudos

Hi there,

I'm getting an Error when i do a oModel.update() request against the Netweaver Gateway.

The following problem occurred: HTTP request failed500,Internal Server Error,{"error":{"code":"CX_SXML_PARSE_ERROR/001560AA0E081DEB8CA398CC1690D406","message":{"lang":"en","value":"Error while parsing an XML stream"}



It's no problem to read or create entities - everything works fine.


So for update with json I do a read on the specific entity.

In my onReadSuccess function i do the oModel.refreshSecurityToken() to get the X-CSRF-Token. (works, too)

Then I define the data which changes.

          var oEntry = {};

          oEntry.ID = id (dynamic);

          oEntry.Name = name (dynamic);


          var oParams = {};

          oParams.fnSuccess = function() {alert("update successful"};

          oParams.fnError = function() {alert("update failed"};


After that I do the oModel.update() in the oModel.read()-onReadSuccess function.

               oModel.update(ServiceUrl, oEntry, oParams);

But here I'm getting error: error while parsing an XML stream

Does anybody know what to do? I read sth. about clearing the results & metadata but don't know how to do with JSON-Model.

Thank you very much

Greetz

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

Hi Tobias, Your request body is json, so I am not sure why it gives a XML parse error.

When you instantiate the model, can you pass the second parameter as 'true' so that json will be set as the content type.? Alos, check in the network tab (in Dev tools) on what is the content-type header sent as.

Former Member
0 Kudos

Got it!

I tried different ways, and I think it was the definition of the oEntry.

I did:

var oEntry = {};

oEntry[" Id "] = Id;

oEntry[" Name "] = name;

I have changed it to:

oEntry.Id = id;

oEntry.Name = name;

and... he did it !

I did   oEntry["id"] =     because i read about it in another thread, that it should work.

Anyway, now I can update.

Thank you very much Krishna.

Greetz

ChandraMahajan
Active Contributor
0 Kudos

Ok so you had error in definition of oEntry. you can also refer Documentation/AdvancedTopics/DataBinding/ODataWrite – SAPUI5 Wiki (TIP CORE User Interface) for examples on how CRUD operations are called on ODataModel.

BR,

Chandra

Former Member
0 Kudos

Krishna ,

I am facing  the same error ..

And content type is application/json in my network tab ,

var oModel1 = new sap.ui.model.odata.ODataModel( serviceUrl ,true);

Also in my constructor i am sending true .

Can you help me how to debug further .

Though i send JSON , i am getting  Error while parsing an XML stream

roger_beach
Participant
0 Kudos

Chandra,

Your link above is no longer working.  Is there a new link you can provide?

ChandraMahajan
Active Contributor
0 Kudos

Hi,

Refer OData Write Support

Regards,

Chandra

roger_beach
Participant
0 Kudos

Awesome Chandra, thanks much!!

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

You can refer thread and Error while parsing an XML stream | SCN on similar kind of error.

Please check if this works!

Regards,

Chandra

Former Member
0 Kudos

Hi,

thank you very much.

But I'm still facing error: error while parsing an XML stream

I debugged and it runs into exception because of the Id (Edm.Int32).

I tried to parse the string to Int in javascript but still getting same error.

Any suggestions?

thank you

Former Member
0 Kudos

I tried to edit the metadata, too.

oEntry = {__metadata:{......

But still: error while parsing an XML stream