>How do I set content-type in my application(incase I need to do that explicitly) and in which file?
You don't set the content type directly. Instead when you create the model set true for the second parameter in the constructor:
oController.oModel = new sap.ui.model.odata.ODataModel("/cd164/admin/solutions/services/user.xsodata/", true); |
This tells UI5 to use JSON instead of ATOM/XML. Then the content-type will automatically be set to application/json.
For instance to create a new record you need only call model.create. Pass the new entity into this method formatted as JSON. Here is an example:
var oModel = sap.ui.getCore().byId("idodataCRUD").getController().oModel;
var oEntry = {};
oEntry.PERS_NO = "0000000000";
oEntry.FIRSTNAME = sap.ui.getCore().byId("fName").getValue();
oEntry.LASTNAME = sap.ui.getCore().byId("lName").getValue();
oEntry.E_MAIL = sap.ui.getCore().byId("email").getValue();
oModel.create('/Users', oEntry, null, function() {
alert("Create successful");
}, function() {
alert("Create failed");
});