Hi Khalil RAHMANI,
From what I understand, you must not have implemented the create entity method in your back end or you have provided the credentials wrong . Share screenshots of your error and code.
You already have an active moderator alert for this content.
Hi Khalil RAHMANI,
Thanks for sharing the screenshots.
I am going to suggest you another method for POST operations, using the create() method in odata. Please go through the foll. link for more information about the method :
https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.ODataModel --- Seach for create under methods
Please refer to the foll. example for better understanding of the POST operation :
Create your model :
var modelo = new sap.ui.model.odata.ODataModel("proxy/http/183.82.98.148:8048/sap/opu/odata/SAP/****_SRV",false,"Your_username","Your_Password");
Now create your form :
var oSimpleForm = new sap.ui.layout.form.SimpleForm("sf1", { content:[ new sap.ui.commons.Label({text:"Empid"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"First Name"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Last Name"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Age"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Mobileno"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Salary"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Eposition"}), new sap.ui.commons.TextField({width : "15em"}), new sap.ui.commons.Label({text:"Email"}), new sap.ui.commons.TextField({width : "15em"}) ]});
Now to POST all the entered data in the form,
function insertData(){ var form = oSimpleForm.getContent(); var entry = {}; entry.Empid = form[1].getValue(); entry.Firstname = form[3].getValue(); entry.Lastname = form[5].getValue(); entry.Age = form[7].getValue(); entry.Mobileno = form[9].getValue(); entry.Salary = form[11].getValue(); entry.Eposition = form[13].getValue(); entry.Email = form[15].getValue(); sap.ui.getCore().setModel(modelo); sap.ui.getCore().getModel().create("/employeeinfoSet",entry,null,function(oResponse){ sap.ui.commons.MessageBox.alert("Create Successfull"); },function(){ sap.ui.commons.MessageBox.alert("Create Failed"); }); }
Your final output looks something like this :
So, by using the model_object.create() method, you can perform POST operation in ODATA.
Hope this helps,
Regards.
Add comment