cancel
Showing results for 
Search instead for 
Did you mean: 

Error while Consuming ODATA Service in Eclipse

Former Member
0 Kudos

Hi Experts,

I created 1 Odata Service in SAP.

I test it in Gateway Client; it is working fine.

But when I am trying to consume the same in Eclipse.

I m failed get the data from SAP as default, also when I am creating a new Record; I am getting Creation failed as an error, which I placed on Creation Button.

Code for CREATE

function openCreateDialog(){

  var oCreateDialog = new sap.ui.commons.Dialog();

  oCreateDialog.setTitle("Create user");

  var oSimpleForm = new sap.ui.layout.form.SimpleForm({

  maxContainerCols: 2,

  content:[

  new sap.ui.core.Title({text:"Person"}),

  new sap.ui.commons.Label({text:"Firstname"}),

  new sap.ui.commons.TextField({value:""}),

  new sap.ui.commons.Label({text:"Lastname"}),

  new sap.ui.commons.TextField({value:""}),

  new sap.ui.commons.Label({text:"City"}),

  new sap.ui.commons.TextField({value:""}),

  new sap.ui.commons.Label({text:"Email"}),

  new sap.ui.commons.TextField({value:""}),

  //new sap.ui.commons.Label({text:"Address"}),

  //new sap.ui.commons.TextField({value:""}),

  ]

  });

  oCreateDialog.addContent(oSimpleForm);

  oCreateDialog.addButton(

  new sap.ui.commons.Button({

  text: "Submit",

  press: function() {

  var content = oSimpleForm.getContent();

  var oEntry = {};

  oEntry.Vorna = content[2].getValue();

  oEntry.Nachn = content[4].getValue();

  oEntry.Ort01 = content[6].getValue();

  oEntry.Mail = content[8].getValue();

  //oEntry.Address = content[10].getValue();

  sap.ui.getCore().getModel().create('/ZODATA1Set', oEntry, null, function(){

  oCreateDialog.close();

  sap.ui.getCore().getModel().refresh();

  },function(){

  oCreateDialog.close();

  alert("Create failed");

  }

  );

  }

  })

  );

  oCreateDialog.open();

  };     

also, my application is not showing any Data when initially. I call it in Browser.

-Regards

Rohit

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184867
Active Contributor
0 Kudos

check in chrome debugger what is the actual reason of error.

Former Member
0 Kudos

How to debug in Chrome.

-Regards

Rohit

former_member184867
Active Contributor
0 Kudos

Run your application in chrome and Press F12 button

Former Member
0 Kudos

Hi,

I am getting;

http://uiserver.com:8000/sap/opu/odata/sap/zodata1_srv/$metadata 401 (Unauthorized)

XMLHttpRequest cannot load http://uiserver.com:8000/sap/opu/odata/sap/zodata1_srv/$metadata. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:49447' is therefore not allowed access. The response had HTTP status code 401.

Regards

Rohit

Former Member
0 Kudos

Hi,

I am getting;

http://uiserver.com:8000/sap/opu/odata/sap/zodata1_srv/$metadata 401 (Unauthorized)

XMLHttpRequest cannot loadhttp://uiserver.com:8000/sap/opu/odata/sap/zodata1_srv/$metadata. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:49447' is therefore not allowed access. The response had HTTP status code 401.

Regards

Rohit

former_member184867
Active Contributor
0 Kudos

This is the behavior of the web browser, You can find more about this issue in UI5 space in SCN. For a quick fix you may refer to  javascript - Disable same origin policy in Chrome - Stack Overflow