Search code examples
odatasapui5sap-gateway

OData Read-Callbacks not triggered in UI5 controller


I need a manual OData call from SAPUI5 to my SAP Gateway (without data binding).

For that, I'm using the following code:

oModel.read("/ZTestSet"),  
    null,null,false, function(oData, oResponse){
       alert("success");
    },
    function(oError ){
       alert("error");
} 

I've debugged it on the SAP system. I received the call and fill the et_entityset with the required data.

The problem is, that no function will be triggered as callback. Neither success nor error (I can't find any error on the gateway or someone else).

Response in Browser's Developer Tools:

HEADERS:
     
Request Method:GET
Status Code:200 OK
     
RESPONSE HEADERS:
cache-control:no-store, no-cache
Connection:keep-alive
content-encoding:gzip
Content-Length:827
Content-Type:application/atom+xml; charset=utf-8
dataserviceversion:2.0
Date:Tue, 05 Apr 2016 12:08:34 GMT
Proxy-Connection:keep-alive
sap-metadata-last-modified:Tue, 05 Apr 2016 10:06:59 GMT

REQUEST HEADERS:
Accept:application/atom+xml,application/atomsvc+xml,application/xml
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US
Cache-Control:no-cache
DataServiceVersion:2.0

RESPONSE:
<feed xmlns="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" xml:base="<<ADDRESS>>">
  <id><<ADDRESS>></id>
  <title type="text"><<FUNCTION>></title>
  <updated>2016-04-05T12:08:34Z</updated>
  <author>
    <name />
  </author>
  <<LIST OF ENTRIES>>
</feed>

Looks like a successful call.


Solution

  • What a silly mistake.

    I closed the parenthesis after the URL. It should be closed naturally after the last parameter. In my case after the error-function.

    Right code:

    oModel.read("/ZTestSet", null, null, false, function(oData, oResponse) {
      alert("success");
    }, function(oError){
      alert("error");
    });