on 09-03-2013 10:35 AM
Hello Experts,
I have created an Odata Service for flight demo.
I have successfully implemented the GET_ENTITY & GET_ENTITYSET methods and tested them.
Now i am trying to implement the CREATE_ENTITY method. Data and Model both classes are up to date.
Now I am trying to call the PUT method of REST in Mozilla Firefox for testing purpose.
I have installed the REST CLIENT Add-on for Firefox.
After clicking the Send button i am getting the below error.
"CSRF token validation failed"
The cause of this error is i have supplied wrong value for x-csrf-token.
My Question is from where can i get the value of x-csrf-token when i am calling an Odata service for testing purpose from a browser with rest client add-on installed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Midhun,
I am trying to POST data to Odata service. My Odata request code is
OData.request(
{
headers: {'x-requested-with' : 'XMLHttpRequest','Content-Type': 'application/xml',
'DataServiceVersion': '2.0',
"X-CSRF-Token":"Fetch" },
requestUri: "proxy/http/vikalpng.vikalpaws.com:8000/sap/opu/odata/sap/ZUSERINFO_VER_SRV/",
method: "GET",
//data: oParameters,
user: "*******",
password: "********"},
function (data, response) {
// success handler
header_xcsrf_token = "tN0lvZGnascNVGnTFFDwGA==";
OData.request(
{
headers: {'x-requested-with' : 'XMLHttpRequest',
'Content-Type': 'application/xml', 'DataServiceVersion': '2.0',
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"X-CSRF-Token": 'tN0lvZGnascNVGnTFFDwGA==' },
requestUri: "proxy/http/vikalpng.vikalpaws.com:8000/sap/opu/odata/sap/ZUSERINFO_VER_SRV/",
method: "POST",
data: oParameters,
user: "********",
password: "*******"},
function (data, response) {
//success handler
console.log(response);
console.log('Successfully updated object');
}
);
I am getting error POST http://gw_admin:vgupta%402013@localhost:8000/Popup/proxy/http/vikalpng.vikalpaws.com:8000/sap/opu/od... 403 (Forbidden)
Uncaught #<Object>
Can you please show me how to resolve the error?
Thanks
Himadri
Hellou gurus, I have similar problem.
I can get collection from SAP gateway (get_entityset is working) but when I try call oModel.update
there is problem with csrf token validation.
So I tried call web service from rest client
and there is not x-csrf token value.
I guess thats why i can not update value from java, because server doesn't give mi csrf token.
Am I right ?
Thank you
PROBLEM 1. with rest client solved, but still cannot update oModel
here is code for update:
var bseg = {
BUKRS:'1000',
BELNR:'12345',
GJAHR:'2015',
BUZEI:'2'};
var oModel = sap.ui.getCore().getModel();
oModel.update('/BSEGCollection', bseg, null, function(){
alert("Update successful");
},function(){
alert("Update failed");});
here is code for create model :
var oModel = new sap.ui.model.odata.ODataModel(getServiceURL(), false, "", "", null,null, null, true);
oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);
sap.ui.getCore().setModel(oModel);
TEst in gateway client :
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check out this blog, [Content Deleted Jan 2014]
Regards
Tahir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.