0

I am trying to create an OData model in SAP UI5 this way:

new sap.ui.model.odata.ODataModel("http://services.odata.org/Northwind/Northwind.svc/");

but I am getting a 501 not implemented error! could you please check what's wrong?

Thanks

Mohamed Ali JAMAOUI
  • 14,275
  • 14
  • 73
  • 117

3 Answers3

0

As far as I can see it, the service is not really CORS-enabled. I have the same problem with my own examples here, as soon as I am not using some kind of proxy, I get this error. The reason behind it is that when you send a complex request to the service, you'll autmatically have a so-called preflight request sent by your browser (before the actual GET) which is not a GET-Request, but an HTTP OPTIONS request. All the odata.org sample services return a 501 error at the moment for such requests. You can e.g. use the simpleProxyServlet which is shipped with UI5, or of course any other proxy which would solve this.

10littleOrcs
  • 151
  • 1
  • 6
0

You are getting this error as your browser will refuse this request due to same Origin Policy. Here is what you should do:

  • Deploy the app on the same server or domain as the service that you want to call, so that both resources are in the same origin (if possible)

  • Disable the same-origin policy in the browser for local testing. Run Chrome by running Chrome with the following command: [your-path-to-chrome-installation-dir]\chrome.exe --disable-web-security --user-data-dir. Make sure that all instances of Chrome are closed before you run the command. This allows all web sites to break out of the same-origin policy and connect to the remote service directly.

    -> Don't do this in your productive app as it imposes a security risk.

  • Using a proxy

The following documentation should help you understand this more and implement:

Nandan Chaturvedi
  • 1,028
  • 3
  • 16
  • 32
-1

Please use "proxy/http/services.odata.org/Northwind/Northwind.svc", I think it's solve your problem!