Integration with sap to servicenow token authentication fail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 10:49 PM
We are working on token-based integration with SAP.
SAP Team has provided the rest API for the token type is “x-csrf-token” it has generated.
We are sending the csrf token in PUT rest API but it is returning as a response is “CSRF token validation failed”.
HTTP Status : 403
Error message : Method failed: (/sap/opu/odata/SAP/ZPTG_USER_UNLOCK_SRV/UserDetailsSet(Bname='KOTI6')) with code: 403 - Forbidden username/password combo
The same web services is working in postman but not in servicneow.
Please let me know if anyone did integration with ServiceNow to SAP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2021 03:43 PM
Hi,
We can try passing the session cookie received along with the csrf token value in the PUT API.
Regards,
Snehal Khare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2021 05:37 AM
Hi,
The CSRF token validation failed issue is resolved by sending Session cookie in the POST message along with the CSRF token.
Get the session cookie using following script:
var cookies = response.getCookies();
//for( var i=0; i < cookies.size(); i++ ){ gs.print('cookie: ' + cookies.get(i)); }
var sapsessionid ='';
var cookiesArray = (''+cookies).split(';');
//iterate through all cookies, found interesting ones
for ( var i = 0; i < cookiesArray.length; i++) {
if( cookiesArray[i].indexOf("SESSIONID") > -1) {
sapsessionid = cookiesArray[i].substring(cookiesArray[i].indexOf("SESSIONID"),cookiesArray[i].length);
}
}
Send the cookie in the POST call as follows along with CSRF token:
r.setRequestHeader('Cookie',sessioncookie);
Regards,
Snehal Khare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 06:06 AM
Was this ever got resolved?