Reputation: 1
I am using serenity rest assured framework, I do the below steps.
1) Using GET request am able to fetch the CSRF token in the response header.
2) Then I try to use the same fetched CSRF token to POST another request and I receive "CSRF token validation failed"
response = RestAssured.given()
.when ()
.contentType (ContentType.JSON)
.queryParam("$top", "10&$filter=ContactID eq 'LZebLLUr590jmVsgpILwAQevxhhHdfjkhdkfjbnkdf' & ContactOrigin='XXXX'&$format=json")
.header("Authorization","Bearer"+" "+SapLoginAPISteps.authToken)
.header("x-csrf-token",SapGetCsrfTokensApiSteps.csrfToken)
.header("Connection",SapGetCsrfTokensApiSteps.Connection)
.header("set-cookie",SapGetCsrfTokensApiSteps.cookie)
.get();
Upvotes: 0
Views: 809
Reputation: 357
The details provided are not enough to suggest a solution, though I think you should keep all the valid data of Authorization, csrf token and cookie. Even if one of these is invalid, service call fails. Try to manually call the service through tools like Postman/Fiddler you will get an idea which one is wrong.
Upvotes: 0