on 2017 May 22 7:13 AM
Hi Experts,
I am not able to update the data in SAP C4C system through standard C4C odata service.I am trying to use method PATCH to update records in in IndividualCustomerCollection node of the c4codata service.Using V2 OdataModel.
While doing this in network the service shows post but data does not get updated in backend.I have also tried the PUT/POST method but with no success.
It gives error "The Data Services Request could not be understood due to malformed syntax". in console response.
I have referred the C4C odata api but could not find an issue with my code
Any suggestions would be appreciated.
Below is my code
var modelData = this.getOwnerComponent().getModel("c4codata");
modelData.setUseBatch(true);
// var path = "/IndividualCustomerCollection" ;
var path = "/IndividualCustomerCollection" + "('" + objid + "')";
var changedata = [];
changedata = {
"FirstName": thatMaster.getView().byId("idfname").getValue(),
"LastName": thatMaster.getView().byId("idlname").getValue(),
"GenderCode": thatMaster.getView().byId("idgender").getSelectedItem().getKey(),
"MaritalStatusCode": thatMaster.getView().byId("maritalstatus").getSelectedItem().getKey(),
"Mobile": thatMaster.getView().byId("idmob1").getValue(),
"EMail": thatMaster.getView().byId("idpermmail").getValue(),
"NoofHomesOwner": thatMaster.getView().byId("idhomeowned").getValue(),
"PriorInvestment": thatMaster.getView().byId("idinvestment").getSelectedItem().getKey(),
"HouseID": thatMaster.getView().byId("idperm1").getValue(),
"StreetName": thatMaster.getView().byId("idperm2").getValue(),
"StreetPostalCode": thatMaster.getView().byId("idperm3").getValue(),
"CityName": thatMaster.getView().byId("idperm4").getValue(),
"Phone": thatMaster.getView().byId("idtele").getValue(),
"AlternateMobileNumber": thatMaster.getView().byId("idmob2").getValue(),
"HighestEducationSelf": thatMaster.getView().byId("ideduself").getSelectedItem().getKey(),
"HighestEducationSpouse": thatMaster.getView().byId("ideduspouse").getSelectedItem().getKey(),
"SpouseName": thatMaster.getView().byId("idspname").getValue(),
"ChildName1": thatMaster.getView().byId("idchild1").getValue(),
"ChildName2": thatMaster.getView().byId("idchild2").getValue(),
"ChildName3": thatMaster.getView().byId("idchild3").getValue(),
"WeddingAnniversary": thatMaster.getView().byId("idAni").getValue(),
"DOBSpouse": thatMaster.getView().byId("idDP2").getValue(),
"DateOfBirth": thatMaster.getView().byId("idDP1").getValue(),
"DOBChild1": thatMaster.getView().byId("idDP3").getValue(),
"DOBChild2": thatMaster.getView().byId("idDP4").getValue(),
"DOBChild3": thatMaster.getView().byId("idDP5").getValue(),
"ProfessionCode": thatMaster.getView().byId("idProfself").getSelectedItem().getKey(),
"CompanyName": thatMaster.getView().byId("idcompself").getValue(),
"EmploymentType": thatMaster.getView().byId("idtype").getSelectedItem().getKey(),
"ResidentialStatus": thatMaster.getView().byId("idresstatus").getSelectedItem().getKey(),
"PurposeofPurchase": thatMaster.getView().byId("idPurchasRsn").getSelectedItem().getKey(),
"SpouseEmailID": {
"schemeID": "",
"content": thatMaster.getView().byId("idemailspou").getValue()
},
"TotalAnnualIncomefromallsources": thatMaster.getView().byId("idtotalinc").getValue(),
"FavoriteHolidayDestinationDomestic": thatMaster.getView().byId("idhilidom").getValue(),
"FavoriteHolidayDestinationInternational": thatMaster.getView().byId("idholiint").getValue(),
"PreferredCuisine": thatMaster.getView().byId("idCuisine").getSelectedItem().getKey(),
"CarDriven": thatMaster.getView().byId("idcardrivern").getValue(),
"InterestHobbies": thatMaster.getView().byId("idhobbiesint").getSelectedItem().getKey(),
"InternetSurfing": thatMaster.getView().byId("idinternet").getSelectedItem().getKey(),
"SpendTimewithFamily": thatMaster.getView().byId("idfamilytime").getSelectedItem().getKey(),
"SportsActivitiesInterested": thatMaster.getView().byId("idsportact").getSelectedItem().getKey(),
"KidsHobbiesInterests": thatMaster.getView().byId("kidshob").getSelectedItem().getKey()
};
modelData.update(path, changedata, {
method: "PATCH",
success: function(OData, oResponse) {
var msgS = "Your Profile has been updated";
sap.m.MessageBox
.show(
msgS, {
title: "Success",
icon: sap.m.MessageBox.Icon.SUCCESS,
onClose: function() {
this._toggleButtonsAndView(false);
thatMaster.formBind();
}
});
},
error: function(err) {
var b = $.parseJSON(err.response.body);
var msg1 = b.error.message.value;
sap.m.MessageBox
.show(
msg1,
sap.m.MessageBox.Icon.ERROR, "Error");
return;
}
});
Request clarification before answering.
Assuming you are using V2 OData Model, "method" is not a parameter for the update method. Refer:
https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/update
You might need to change the "defaultUpdateMethod" property when creating the model. Refer to these options:
https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.UpdateMethod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did u try the same thing in some tool? like postman or soapui?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi! Did you solve the issue? I am facing the same error with POST method for Corporate Accounts.
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
65 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.