on 03-02-2015 6:27 AM
Hi Experts,
I'm using Odata services, Everything is working fine Except the moment when I try updating or using "PUT" operation.
In the gateway side while using the same URL, I been able to update it but the same is not happening through SAPui5,
I'm getting a 403 forbidden error, attaching a screen shot of the error.
I try reading other blogs, but it was not helpful...I can even post the codes also if anybody want it.
Need help !
Regards,
Ashwin
Hello Ashwin,
Issue could be because of CSRF token as well. Check this as well.
Use the metadata URL of your Update Service or any GET service URL and First fetch the toke value by passing the header ' X-CSRF-Token ' and value as ' fetch '.
Once you get the token value in the response headers, Please pass that particular token in the header ' X-CSRF-Token ' and value as ' <xxxxxxxxxx> '.
The below would help ->
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi...
Is any one help me out this error...
i am getting response as below in browser...
<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>005056A509B11ED199D8826D151FC0FE</code><message xml:lang="en">The specified HTTP method is not allowed for the resource identified by the Data Service Request URI</message><innererror xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><transactionid>BEB80BE629F4F1D4BE730050569C4F03</transactionid><timestamp>20160426141119.7080000</timestamp><Error_Resolution><SAP_Transaction>Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more details</SAP_Transaction><SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note></Error_Resolution></innererror></error>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try using MERGE or PATCH instead of PUT in method type. I hope this will solve your problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all,
Thanks all for your valuable feedbacks and guidance.
It is now working for me...problem was with the way I was passing the values into the URL.
Thanks,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi.. I'm facing the exact same issue. I checked the pay load but I can't see anything this wrong. Can you plese help? Here is my payload.
Hi.. I'm facing the exact same issue. I checked the pay load but I can't see anything this wrong. Can you plese help? Here is my payload.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is it something to do with "x-csrf-token",
if yes then how to pass these tokens??
Thanks,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sree,
Well I'm not using oModel.create as i"m directly taking values from the form and sending it to the backend. I tried working on CSRF and managed to resolve 403 forbidden error...while now it gives another error saying bad request #400.
well I will post the code for which I'musing for POST operation:
Note: changed my url for security reasons.
var mid = $("#mrid1").val();
var url = "http://"myUrl"/"my \enityset"('"+mid+"')";
OData.request({
requestUri : "http://"my url",
method : "GET",
headers : {
"X-Requested-With" : "XMLHttpRequest",
"Content-Type" : "application/xml ",
"DataServiceVersion" : "2.0",
"X-CSRF-Token" : "Fetch",
"Accept": "application/xml",
}
},
function(data, response) {
console.log(response);
var header_xcsrf_token = response.headers['x-csrf-token'];
var requestObj1 = {
requestUri: '',
method: '',
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/xml",
"X-CSRF-Token": header_xcsrf_token,
"DataServiceVersion": "2.0",
"MaxDataServiceVersion": "2.0",
"Accept": "application/xml",
},
};
var method = "PUT";
requestObj1.requestUri = url;
requestObj1.method = method;
requestObj1.data = newData;
OData.request(requestObj1, function() {
this.resetForm();
});
and this is th new network tab error
Thanks,
Ashwin
Hello Ashwin,
Try passing the Key inside the URL and check. Say UserID is the key of the GW Model, then pass
http://"host".com:8800/sap/opu/odata/sap/ZISU_SM_SRV_01/<YourEntitysetName>/(UserID='2002')
If its failing then,
Now you need to look into the format of payload which is generated from your UI is correct or not.
Check the format.
If format is also correct check Content Type Header. Try below ones.
{
"Carrid":"AF",
"Connid":"0820"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can you get the details from the network tab in debugger ? there you will get exact error details. Code the code snippet too.
Sree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.