cancel
Showing results for 
Search instead for 
Did you mean: 

Error while connecting with the url using odata...please help

former_member213574
Participant
0 Kudos

hi All,

I was trying to do one basic ODATA example which i got from the threads.

<!DOCTYPE html>

<html><head>

  <meta http-equiv='X-UA-Compatible' content='IE=edge' />

  <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

  <title>Table with OData Binding</title>

     <script id='sap-ui-bootstrap' type='text/javascript'

        src='https://sapui5.hana.ondemand.com/resources/sap-ui-core.js'

        data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table"

  data-sap-ui-theme="sap_bluecrystal"></script>

  <script>

  // the root URL of the OData service - prefixed with a local URL to a proxy which forwards the request,

circumventing cross-domain restrictions

  // IMPORTANT: this proxy must be available for the code example to run!

  var url = "http://services.odata.org/Northwind/Northwind.svc";

// create an ODataModel from URL

  var oModel = new sap.ui.model.odata.ODataModel(url, true);

  var oTable = new sap.ui.table.Table("sampleTable");

  oModel.read("/Customers",null,null,null,function(){

  var metadata = oModel.getServiceMetadata();

  var entityCustomerRef = metadata.dataServices.schema[0].entityType[2];

  var listOfProperties = entityCustomerRef.property;

  for ( var i = 0; i < listOfProperties.length; i++) {

  oTable.addColumn(new sap.ui.table.Column().setLabel(

  new sap.ui.commons.Label({

  text : listOfProperties[i].name,

  })).setTemplate(

  new sap.ui.commons.TextField().bindProperty("value",

  listOfProperties[i].name))) }

  oTable.setModel(oModel); // set model to Table

  oTable.bindRows("/Customers");

  });

  oTable.placeAt("content"); // place model onto UI

  </script>

  </head>

  <body class='sapUiBody'>

  <div id='content'></div>

  </body>

</html>

but when i try to execute the same it is not loading any data and showing the error as :

2014-07-21 16:04:05 (default) : https://sapui5.hana.ondemand.com/resources/ - sap.ui.ModuleSystem sap-ui-core.js:80

2Failed to load resource: the server responded with a status of 501 (Not Implemented) http://services.odata.org/Northwind/Northwind.svc/$metadata

XMLHttpRequest cannot load http://services.odata.org/Northwind/Northwind.svc/$metadata. Invalid HTTP status code 501 odata.html:1

  1. 2014-07-21 16:04:16 The following problem occurred: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://services.odata.org/Northwind/Northwind.svc/$metadata'. -  sap-ui-core.js:80
Failed to load resource: the server responded with a status of 501 (Not Implemented) http://services.odata.org/Northwind/Northwind.svc/CustomersXMLHttpRequest cannot load http://services.odata.org/Northwind/Northwind.svc/Customers. Invalid HTTP status code 501 odata.html:1
  1. 2014-07-21 16:04:17 The following problem occurred: HTTP request failed0,, -  sap-ui-core.js:80;;

But i can launch the url with metadata through browser..kindly help???

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I have 2 apps, one UI5 and XS.

The XS expose a oData Service and the UI5 consume it.

But I'm getting this error when the SapUI5 try to get the data from the XS app.

Can anyone help me to solve it?

Thanks

ranjit_rao
Participant
0 Kudos


Hi Arun,

replace the following line in your code:

var url = "http/services.odata.org/Northwind/Northwind.svc";

with the following:

var url = "proxy/http/services.odata.org/Northwind/Northwind.svc";

It will either work fine or this error will be skipped.

former_member213574
Participant
0 Kudos

Hi Ranjit,

I think you didn't get my doubt clearly, I am able to connect url and create the table from the above code if i run this as a web application.

I am looking to create the same application as an android app, and for that purpose how should i proceed, if i directly convert this web app to android app it is not fetching the data from the url, so I hope there is some way of creating an odata consuming android app, I am looking for that solution.

Regards,

Arun

ChandraMahajan
Active Contributor
0 Kudos
former_member213574
Participant
0 Kudos

Hi Chandrashekhar,

how will we add authentications also in this method??? do you have any working example with that?

Also why we are switching to json.model instead of the conventional way, var oModel = new sap.ui.model.odata.ODataModel

Thanks and regards,

Arun

former_member213574
Participant
0 Kudos


Hi Chandra,

Need to POST some data to some ODATA service, is it possible to get any sample code, I tried with bank crud but it is too complex..need something which is less complicated?

former_member213574
Participant
0 Kudos

Hi All,

When I tried to do the POST operation I am getting the error 403 and i have done the Fetch method to get the token, but even though it is not working...Is the "login/ticket_only_by_https" to 0 is the only solution.....

Regards,

Arun