cancel
Showing results for 
Search instead for 
Did you mean: 

I have an error while performing create operation with oData whats the problem here

Former Member
0 Kudos
  1. Object
    1. message:"no handler for data"
    2. __proto__:Object
    1. __defineGetter__:__defineGetter__()
    2. __defineSetter__:__defineSetter__()
    3. __lookupGetter__:__lookupGetter__()
    4. __lookupSetter__:__lookupSetter__()
    5. constructor:Object()
    6. hasOwnProperty:hasOwnProperty()
    7. isPrototypeOf:isPrototypeOf()
    8. propertyIsEnumerable:propertyIsEnumerable()
    9. toLocaleString:toLocaleString()
    10. toString:toString()
    11. valueOf:valueOf()
    12. get __proto__:__proto__()
    13. set __proto__:__proto__()
sap.ui
		.controller(
				"club.club.Create",
				{
					onInit : function() {
					},
					handleBackPress : function(oEvent) {
						var oRouter = sap.ui.core.UIComponent
								.getRouterFor(this);
						oRouter.navTo("schedule");
					},
					handleSubmitPress : function(oEvent) {
						var oId = this.getView().byId("MatchId");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("MatchDate");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("HomeTeam");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("AwayTeam");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("MatchType");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("Week");
						oId.setEditable(true);
						oId.setValue("");
						var oId = this.getView().byId("Location");
						oId.setEditable(true);
						oId.setValue("");
						var oForm = this.getView().byId("createForm");
						var MatchId = this.getView().byId("MatchId").getValue();
						console.log(MatchId);
						var MatchDate = this.getView().byId("MatchDate")
								.getValue();
						var HomeTeam = this.getView().byId("HomeTeam")
								.getValue();
						var AwayTeam = this.getView().byId("AwayTeam")
								.getValue();
						var MatchType = this.getView().byId("MatchType")
								.getValue();
						var Week = this.getView().byId("Week").getValue();
						var Location = this.getView().byId("Location")
								.getValue();
						OData
								.request(
										{
											requestUri : "http://eccehp7.erp.com:8000/sap/opu/odata/sap/ZYK_SCHEDULE_SRV_01",
											method : "GET",
											user : "",
											password : "",
											headers : {
												"X-Requested-With" : "XMLHttpRequest",
												"Content-Type" : "application/json",
												"DataServiceVersion" : "2.0",
												"X-CSRF-Token" : "Fetch",
												"Access-Control-Allow-Origin" : "*",
												"Access-Control-Allow-Methods" : "GET,PUT,POST,DELETE,OPTIONS",
												"Access-Control-Allow-Headers" : "Origin, Content-Type, Authorization, Accept, X-Request-With",
												"Access-Control-Allow-Credentials" : "true",
												'Authorization' : 'Basic '
														+ btoa("username"
																+ ':password')
											}
										},
										function(data, response) {
OData.request({
																requestUri : "http://eccehp7.erp.com:8000/sap/opu/odata/sap/ZYK_SCHEDULE_SRV_01/SheduleSet",
																method : "POST",
																headers : {
																	"X-Requested-With" : "XMLHttpRequest",
																	"Content-Type" : "application/atom-xml",
																	"DataServiceVersion" : "2.0",
																	"Accept" : "application/atom-xml,",
																	"X-CSRF-Token" : response.headers['x-csrf-token'],
																	"Access-Control-Allow-Origin" : "*",
																	"Access-Control-Allow-Methods" : "GET,PUT,POST,DELETE,OPTIONS",
																	"Access-Control-Allow-Headers" : "Origin, Content-Type, Authorization, Accept, X-Request-With",
																	"Access-Control-Allow-Credentials" : "true",
																	'Authorization' : 'Basic '
																			+ btoa("username"
																					+ ':password')
																},
																data : {
																	MatchId : MatchId,
																	MatchDate : MatchDate,
																	HomeTeam : HomeTeam,
																	AwayTeam : AwayTeam,
																	MatchType : MatchType,
																	Week : Week,
																	Location : Location,
																}
															},
															function(data,
																	request) {
																var oSubDialog = new sap.ui.commons.Dialog(
																		{
																			title : "Created",
																			content : [ new sap.ui.commons.Label(
																					{
																						text : "Data Created Successfully"
																					}) ]
																		});
																oSubDialog
																		.open();
																oSubDialog
																		.addButton(new sap.ui.commons.Button(
																				{
																					text : "Ok",
																					press : function() {
																						oSubDialog
																								.close();
																					}
																				}));
																sap.ui
																		.getCore()
																		.getModel()
																		.refresh();
															},
															function(err) {
																//alert("Create Error");
																console.log(err);
															});
										}, function(err) {
											var request = err.request;
											var response = err.response;
											alert("Error in Post Method"
													+ request + "Response"
													+ response);
										});
					}
				});

this is my controller file

Accepted Solutions (0)

Answers (0)