cancel
Showing results for 
Search instead for 
Did you mean: 

Unable To Create/Post through Mysql Odata Service

Former Member
0 Kudos

Hello Everyone,

I am making a SAPUI5 application where I need to use mysql database, to acheive that I created an Odata Service from :

http://scn.sap.com/community/gateway/blog/2014/02/05/odata-producer-using-apache-olingo-with-mysql-j...

I have two tables : Login, Session

I followed each and every step and I got the service:

When I am trying to read the data its working perfectly through the following code:

    gatewayLoginLink = "proxy/http/localhost:8080/login/login.svc";

    var path="/Sessions?$format=json"

   var iModel =  new sap.ui.model.odata.ODataModel(gatewayLoginLink, true);

     iModel.read(path, null, null, true,

     function(oData1,oResponse)

     {

      var oJSONmodel = new sap.ui.model.json.JSONModel();

      oJSONmodel.setData({

      modelData : oData1.results

     });

     alert("Successful");

     },

     function(oError) {

          alert("Error");     

    });

But When I am trying to write through following code:


var value=

  {

    loginid:"11",

    password:"1"

  };

   oModel.create('/Logins', value, null, function(oData,

            oResponse){

   alert("Success Create");

       },function(){

   alert("Error Create");

  });

Its giving Error on console:

Kindly Help me out please.

If there is any different way to access mysql database through sapui5 app kindly tell me that too, it would be great help.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos

test ur service with postman first

make sure they are working

Former Member
0 Kudos

Hello Sir,

I tested the service in Advanced Rest Client :

Its giving 200(OK) during GET but when I tried for POST :

and the response:

and the description:

I am new at this stuff ,I am not getting any of the description ,Please help.

Sathees_P
Participant
0 Kudos

Hi Vinayak,

Creation of entity generally fails in OData V2 apache onlingo java lib if we use JSON=True.

Create model with json: false then will work, create a odata model like below.

new sap.ui.model.odata.ODataModel(sServiceUrl, {json: false});

Former Member
0 Kudos

Thank you so much sir. Issue Resolved.

Answers (0)