How to perform a post operation in Odata service from sapui5 mobile application is
explained here.x-csrf token handling will be done by the SAPUI5 OData model api.we dont have to worry about that.
Pre-requisites
1.odata service
2.sapui5 library files loaded
Steps
Steps
- Instantiate OData model
- Create new entry which is to be posted to the service.
- Call create method of OData model passing the newly created entry
var oModel = new sap.ui.model.odata.v2.ODataModel( "http://<host>:<port>/sap/opu/odata/sap/ZTEST_ODATA_SRV_01", true, "", " " );
var oEntry = {}; oEntry.Carrid = "AFO"; oEntry.Carrname = "Airforce One"; oEntry.Currcode = "USD"; oEntry.Url = "www.techippo.com";
oModel.create("/FlightSet", oEntry, { method: "POST", success: function(data) { alert(JSON.stringify(data)); }, error: function() { } });
If you enjoyed this post, Please Share!!
0 comments :
Post a Comment