Search code examples
odatasapui5netweaver

OData service authentication with SAP Gateway service OpenUI5


i have a service url as below

http://<hostName>:2020/sap/opu/odata/sap/ZTEST_SRV$metadata

When i call this from Chrome browser i ask for username and password if i give username and password, it will show the XML with all the entity sets in that service URL

but in code if i create the instance

var model = new sap.ui.model.odata.v2.ODataModel("http://<hostName>:2020/sap/opu/odata/sap/ZTEST_SRV/",true,'username','password');

its shows the 401 Error

how can i solve this?

My app is not deployed in ABAP repo, or Fiori, this is deployed in other Host on Tomcat


Solution

  • We can solve this is 2 ways

    1: We can use SimpleProxyServlet

    2 Establish a Reverse Proxy with Apache HTTP Server