cancel
Showing results for 
Search instead for 
Did you mean: 

Recieve OData failed with 401

Former Member
0 Kudos

Hi,

i will recieve an ODataService from SMP where a Service is configured with authentification and a simple username and password.

I will recieve the data with the following lines in the onInit-Function in my view-controller:

var oModel = new sap.ui.model.odata.ODataModel( 

                               "http://xxx.xxx.xxx.xxx:8080/gateway/odata/SECUREPROF/DEMO", 

                                                   false, 

                                                   "username", 

                                                   "password"); 

If I put the url in the browser I can recieve all kind of data but not in my application.

Has anybody an idea, what can be wrong?

Something I have tested but nothing will help!

I hope that somebody of you can help me.

Thanks,

Peter

Accepted Solutions (0)

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi Peter,

Can you press F12 in chrome browser and let us know more on error you are getting. 401 is for unauthorized access. I guess you might be getting errors related SOP

Regards,

Chandra

Former Member
0 Kudos

Thanks for your reply,

what do you want to see?

I can not see any other things on this screen!?

Do you have an idea, how I can fix the error, when it is SOP?

Thanks,

Peter

ChandraMahajan
Active Contributor
0 Kudos

Hi,

If it is related to SOP then you can refer this blog and try it out.

meanwhile try to point out your src (in bootstrap script )to below cloud based sapui5 runtime just to check if it works with this.

src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"

Regards,

Chandra

Former Member
0 Kudos

Hi..

thanks for your link. I have disabled SUP in Chrome but the same error comes.

I don't know what I can do. I have replaced the source of sap-ui-core.js, but nothing happends.

Thanks,

Peter

Former Member
0 Kudos

Hi..

i have read some articels and other information about this and one articel helps me to solve my problem. Only works for my Workspace and only (I don't know why) in the browser on my Desktop and not in the browser of my smartphone, but it works.

Partsolution was:

Set URL as Proxy-URL like proxy/server:port/.....

Set proxy in web.xml like

   <context-param>

    <param-name>com.sap.ui5.proxy.REMOTE_LOCATION</param-name>

    <param-value>http://server:port</param-value>

  </context-param>

This is explained here:

When anybody has an idea, why this don't work on smartphone, please tell me.

Greats,

Peter