Skip to Content
0
Dec 18, 2013 at 09:03 AM

ODataModel constructor authentication not working?

409 Views

Hi all,

I've ran into a small issue with my SAPUI5 code. I've created a very simple SAP NetWeaver Gateway service and I am able to test this via restclient (in chrome or via the application).

Now when I do the following in my sapui5 controller

showSecondPage: function() { var oAppData = sap.ui.getCore().getModel("app").getData(); var oModel = new sap.ui.model.odata.ODataModel(oAppData.BaseURL, false, "user", "password"); sap.ui.getCore().setModel(oModel); sap.ui.getCore().getEventBus().publish("nav", "to", { id : "ProductList" }); }

Then I get following error on chrome when testing it

In the developers tool (Network section) i see that the $metadata call is formatted this way:

<user>:<password>@server:port/sap/opu/odata/sap/<GW_SERVICE>/$metadata

And the response for this call is the login-form from SAP

The thing is when i open another tab in chrome and go manually to the metadata url and log in there it just works.

So did i forget to do something in my code to get through this loginform directly by the ODataModel constructor?

Thanks in advance.

Kind regards,

Robin