I have created a service, below is the structure:
I am fetching data successfully from that service. Then displaying as a Smart table, as indicated below:
<smartTable:SmartTable id="detailRecordsSmartTable" entitySet="ZI_BSLiquidityGroups" smartFilterId="" tableType="Table"
useExportToExcel="true" beforeExport="onBeforeExport" useVariantManagement="true"
useTablePersonalisation="true"
header=""
showRowCount="true"
persistencyKey="DetailRecordsSmartTable_persistency"
enableAutoBinding="true"
class="sapUiResponsiveContentPadding"
customData:useSmartField="true"
editTogglable="true"
editable="false"
initiallyVisibleFields="Bukrs,Azdat,Ktonr,Belnr,Kukey,Esnum,Vgman,Texts,Lqpos,Texts,Kwbtr"
beforeRebindTable=".onBeforeRebind">
Table has an additional button, to create new entries. Since the smart table control it has enabled the auto binding, I have created a popup to enter the data, and once user hits save, below code gets triggered for the Create:
onSaveDialog : function () {
var oModel = this.getModel(),
data = {};
data.Bukrs = this.getView().getModel("InputData").getProperty("/Bukrs");
data.Kotnr = this.getView().getModel("InputData").getProperty("/Kotnr");
data.Azdat = this.getView().getModel("InputData").getProperty("/Azdat");
//data.Belnr = "111";
//data.Kukey = "222";
//data.Esnum = "333";
data.Kwaer = this.getView().getModel("InputData").getProperty("/Kwaer");
data.Kwbtr = this.getView().getModel("InputData").getProperty("/Kwbtr");
data.Texts = this.getView().getModel("InputData").getProperty("/Texts");
data.Lqpos = this.getView().getModel("InputData").getProperty("/Lqpos");
data.Zregcl = this.getView().getModel("InputData").getProperty("/Zregcl");
data.Zregfe = this.getView().getModel("InputData").getProperty("/Zregfe");
data.Zregus = this.getView().getModel("InputData").getProperty("/Zregus");
// Create a new entry through the table's list binding
//oModel.setHeaders({"content-type" : "application/json;charset=utf-8"})
oModel.setHeaders({
"content-type" : "application/json;type=entry;charset=utf-8"})
oModel.create(
"/ZI_BSLiquidityGroups", data
, null, {
success : function(oData, response) {
console.log("Create successfull");
},
error : function(oError) {
console.log(oError.responseText)
var msg = oError.responseText.split('message')[3];
MessageToast.show(msg);
}
});
//oModel.submitChanges();
this.byId("AddDialog").close();
this.getView().byId("detailRecordsSmartTable").rebindTable(true);
// Trigger event so Master View gets updated with latest changes
var oEventBus = this.getOwnerComponent().getEventBus();
oEventBus.publish("DetailTable", "Updated", this);
var msg = this.getView().getModel("i18n").getResourceBundle("detail.newRecordSaved");
MessageToast.show(msg);
},
But no matter what I try, I always get the same response:
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">005056A509B11EE3AEB5819C07C69E2F
The server is refusing to process the request because
the entity has an unsupported format
Does anyone have any idea on what I am doing wrong here? I just can't find it
Regards, Martin
Solved by myself. Issue was a wrong parameter being passed to the create method. The null shouldn't be there