Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

UI5 Ajax Request to GW Service

Im trying to store some data to my created GW service which is bind to a RFC FM.

But i get a 500 internal error.

GET http://<host>:<port>/sap/opu/odata/sap/ZMOBILE_SRV_01/Protokolle?IvPspnrS=P-4433&IvPosidS=P-4433&IvTcode=SE13&IvBeschr=test&_=1410368050273 500 (Internal Server Error)

var oParameters= {

           "IvPspnrJ" : "P-4433",

           "IvPspidJ": "P-4433",

           "IvPspnrS": "P-4433",

           "IvPosidS": "P-4433",

           "IvTcode": "SE13",

           "IvBeschr": "test"

         };

$.ajax({

           url : "/sap/opu/odata/sap/ZMOBILE_SRV_01/Protokolle",

           contentType : "application/json",

           dataType : 'json',

           data: oParameters,

           success : function(data, textStatus, jqXHR) {

             alert("success");

           }

         });

In the SAP Netweaver Gateway Client i can create these values so the service is running correctly. Is the call to the service wrong ?

Tags:
Former Member
Former Member replied

My proceed was wrong i tried to use Ajax but im working with an OData service.

i have to use the OData model and its create function.

below is the new and working code:

var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZMOBILE_SRV_01", false);

         //sap.ui.getCore().setModel(oModel);

        

         var oEntry = {};

         oEntry.IvPspnrJ = "P-4433";

         oEntry.IvPspidJ = "P-4433";

         oEntry.IvPspnrS = "P-4433";

         oEntry.IvPosidS = "P-4433";

         oEntry.IvTcode = "SE19";

         oEntry.IvBeschr = "Test";

        

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

         oModel.create('/Protokolle', oEntry, null, function(){

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

             alert("Create ok");

           },function(){

             alert("Create failed");

           }

         );

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question