HI All,
I create an Odata Service to display and create an employee record, both create and display fine from back end testing...
However when I consume the Odata anf built a fiori app, Display is working fine.. for create I placed a button on button click in the action I am calling the POST with Data...
However I am getting the error 403, I tried to get CSRF token and passed for posting.. set CSRF setting on Service to 0 as per note "1896961 - HTTP/HTTPS Configuration for SAP NetWeaver Gateway" , tried with disabling the web security on the Google chrome.. Tried CORS entension of google chrome.. I also followed the Blog "Building a CRUD Application with SAPUI5 Using Odata Model"
In the Program, I seee
Could you please help me with the same..
Please find the Code below...
onCreate: function(oEvent) {
var oEntry = {};
var oView = this.getView();
oEntry.Email = oView.byId("Email_IP").getValue();
if (!Document.prototype.createAttributeNS) {
Document.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
var dummy = this.createElement("dummy");
dummy.setAttributeNS(namespaceURI, qualifiedName, '');
var attr = dummy.attributes[0];
dummy.removeAttributeNode(attr);
return attr;
};
}
if (!Element.prototype.setAttributeNodeNS) {
Element.prototype.setAttributeNodeNS = Element.prototype.setAttributeNode;
}
OData.request({
requestUri: "http://server/sap/opu/odata/sap/Z_TEST_CREATE_EMP_DATA_SRV/EmpDataSet/?$filter=Email eq 'bk@abb.net'",
method: "GET",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token": "Fetch"
}
},
function(data, response) {
header_xcsrf_token = response.headers['x-csrf-token'];
OData.request({
requestUri: "http://server/sap/opu/odata/sap/Z_TEST_CREATE_EMP_DATA_SRV/EmpDataSet",
method: "POST",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"X-CSRF-Token": header_xcsrf_token
},
data: {
Email: oEntry.Email
}
});
});},