cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to read odata response in UI5

0 Kudos

hi,

I'm using below fun to post data to SAP, the data has been added successfully to SAP, but I'm unable to debug the response data from the Odata.

the messageToast for "Done" never reached.

From the odata side, I already filled the er_entity to display the inserted data, so it's not an empty response. I also tested it using sap gateway and the response has data.

But here I cannot read the response.

		postData: function(oEvent) {
		
			var oEntry = {};
			oEntry.Firstname = this.byId("txtFirstname").getValue();
			oEntry.Lastname = this.byId("txtLastname").getValue();
			oEntry.Address = this.byId("txtAddress").getValue();
			oEntry.Postal = this.byId("txtPostal").getValue();
			
			this.getOwnerComponent().getModel("employee").
			create("/employeesSet", oEntry, null, function(response) {
				MessageToast.show("Done");
			}, function(Error) {
				MessageToast.show("Customer Creation Failed  " );
			});
		},<br>

Please help

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

abdul_kareem
Explorer

Hello Samuel,

Can you try like this ? Remove the 'null'.

Add the parameter "odata" and "response" or any name whatever you want in "success" function.

myModel.create('/employeeSet', oEntry, {
				success : function(oData, oResponse) {
					alert('Record Created Successfully...');
				},
				error : function(err, oResponse) {
					
				}
			});
0 Kudos

@ABDUL KAREEM Thank you, it works.

FiratAsan
Active Participant
0 Kudos

Thanks ABDUL KAREEM. But i did not understand why Samuel's code working. Before i have used same code for another project, it was working properly.