cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP request failed after OData update() method

dunayevsky_yuri
Participant
0 Kudos

Hello,

I have a strange issue - after I use update() method of the sap.ui.model.odata.ODataModel class, I can't make read() from the OData model.

I use Northwind OData service, V2.

I can do as much read() actions as I want - everything works fine.

But after I update() for the first time after the page is loaded and try to make read(), I get the following error:



GET https://webidetesting<appname here>-<account name here>.dispatcher.hana.ondemand.com/nort…iexfh2tyudc5p4qhx5gdf))/OData/OData.svc/Products?$filter=(Rating%20eq%201) 500 (Internal Server Error)

HTTP Status 500 - HTTP protocol error occurred while connecting to remote host http://services.odata.org


When I reload the page and make read(), I can see that the update was successful.


Here is my update() method:



sap.ui.getCore().getModel("odata").update(

            "/"+sSourceTable,

            oUpdate,

            {   

                merge: true,

                async: false,

                success: function(){ 

               console.log("Success!");

             }, 

                error: function(oError){ 

                    console.log("Error!"); 

                    console.log(oError); 

                }

            }

        );


Any ideas why this may happen?


Thank you.


Accepted Solutions (0)

Answers (3)

Answers (3)

dunayevsky_yuri
Participant
0 Kudos

Update: it seems like the problem arises when I try to do something with metadata.

If after update() I try to refresh the metadata: sap.ui.getCore().getModel("odata").refreshMetadata();

I get server error 500, but then I all my queries work fine without reloading the page.

former_member182372
Active Contributor
0 Kudos

Yuri, why would need to refresh the metadata?

dunayevsky_yuri
Participant
0 Kudos

I try to figure out what is going on with server error after update method.

So, I want to locate where exactly the error comes from. Now I know that the error comes from metadata.

How did I get to refreshing metadata? Honestly, I got out of logical suggestions and started to do thing to see what will happen.

But it showed, that if I do that refresh, I get error, and after that I can do queries again.

former_member182372
Active Contributor
0 Kudos

Yuri, metadata of OData service is not something you usually refresh from UI, seems like it has a side effect of fixing your issue but refreshing metdata is realativelly "heavy" operation

dunayevsky_yuri
Participant
0 Kudos

I still can't get it work. No idea what is happening here...

former_member182372
Active Contributor
0 Kudos

well, service returns 500. it is not UI, it is service

what is the difference in refresh which is working and the one which is not?

dunayevsky_yuri
Participant
0 Kudos

The order is as follows:

1) I make update(),

2) I make update() or read() again,

3) the page is hung, it waints for reply from the server - it takes about 10-15 secs,

4) I get the errors

5) I refresh the page.

6) everything works again (until I run update() method).

No other delays, except the one in item 3.

former_member182372
Active Contributor
0 Kudos

no, i mean from HTTP network perspective

doers the second read produces the same


Products?$filter=(Rating%20eq%201)


url or different?

dunayevsky_yuri
Participant
0 Kudos

Here are 2 errors of the read() right after the update():


GET<......>/OData/OData.svc/Products?$filter=(Rating%20eq%201) 500 (Internal Server Error)

HTTP Status 500 - HTTP protocol error occurred while connecting to remote host http://services.odata.org

Same errors I get from all next read() and update() methods until I refresh the page.

former_member182372
Active Contributor
0 Kudos

Yura, you do

async: false


that's why ,  "the page is hung"

dunayevsky_yuri
Participant
0 Kudos

Nope, I just commented this line and ran the app.

The page still hangs.

Oh, and this issue is relevant for 2-way OData service.

I tried to update the same property at 1-way and, of course, I couldn't, but I still was able to read() after that unlucky update().

Here is my read() method (pretty much the same as update()):


     sap.ui.getCore().getModel("odata").read(

            "/"+sSourceTable,

            {

                async: false,

                filters: aFilter,

                success: function(oData, oResponse){ 

                    console.log(oData); 

                }, 

                error: function(oError){ 

                    console.log("Error!"); 

                    console.log(oError); 

                }

            }

        );

former_member182372
Active Contributor
0 Kudos

really, any particular reason why calls are async: false??

dunayevsky_yuri
Participant
0 Kudos

Yes,

I have the following lines in my prepareQuery() function (which reads values from fields and prepares filters for read() call):


var oQueryResult = sap.ui.getCore().byId("idView1").getController().doQuery(sSourceTable, aFilter);

sap.ui.getCore().byId("idView1").getController().getSelectedColumns(oQueryResult, sAction);

If I use async: true, then oQueryResult object which is passed to getSelectedColumns() function is null.

And if I put "return oData;" from the doQuery() function under success property's function (and not after read() call), oQueryResult object is undefined.

Only when I set async: false, and only when "return oData;" is located after read() call I have all the results passed to other functions correctly.

Maybe I'm missing something here; I'm still learning.

But this "500 server error" issue is much more disturbing - it ruins my app.