Hi experts!
I need help with a problem.
I have created a service in back-end. Using Gateway Client I can GetEntitySet/GetEntity/Create with no problems.
When I make my code in UI5 I struggle with an error when I try to use ODataModel.create.
Please see the code here:
..
var jsonSaveData = {};
jsonSaveData.Lunchdate = gDate;
jsonSaveData.Username = gUserName;
jsonSaveData.Firstname = gFirstName;
jsonSaveData.Lastname = gLastName;
jsonSaveData.Loc = parseInt(gLoc);
jsonSaveData.Noof = gNoOfGuests;
// Connect to BE
var oModelSaveDataBE = undefined;
try {
oModelSaveDataBE = new sap.ui.model.odata.ODataModel(gServiceURL+gServiceNameLogData, true,gServiceUser, gServicePassword, null);
}
catch(ex) {
alert("exception: "+ex);
}
finally {
// Do nothing here!
}
if ( oModelSaveDataBE != null ) {
// Create new entry in BE
var oAbort = undefined;
oModelSaveDataBE.setHeaders({"content-type" : "application/atom+xml"});
try {
oAbort = oModelSaveDataBE.create(
"/Data",
jsonSaveData,
null,
function doSaveLunchData_OnSuccess(oData, response) {
alert(" doSaveLunchData_OnSuccess()");
logSaveData = oData.results;
},
function doSaveLunchData_OnError(oError) {
alert(" doSaveLunchData_OnError()");
alert("error: "+oError);
}
);
}
catch(ex) {
alert("exception: "+ex);
}
finally {
if ( oAbort != null ) {
// Do something with the oData returned
};
}
..
My .create always return with an error. I have no idea what the oError object contains and what format it has. Where can I find info about it?
The error I get is not helpful at all. There are no logs in back-end. The Create method is not called at all (i set break-point).
Really hope someone can help with this
PS: Please ask if you need more information.
Best regards,
Kell Vagtholm