Error 403 No valid crumb was included in the request

1,299 views
Skip to first unread message

Xinxing Cheng

unread,
Nov 4, 2020, 2:13:30 AM11/4/20
to REST assured
Hi all,

I am using testNG+rest-assured+spring boot for API testing. But always got 403 error with msg is  "No valid crumb was included in the request". Actually I don't need to any CSRF.
I get exepected result with same reqeust by postman.

The curl reqeust by postman is:
curl --location --request POST 'http://localhost:8080/airway/configs' \
--header 'Content-Type: text/plain' \
--data-raw 'gs://service1/hk/dev/develop/routes.yml'

The scripts by spring boot is 
given()
.body("gs://service1/hk/dev/develop/routes.yml")
.when()
.post("http://localhost:8080/airway/configs")
.then()
.log().body();

build.gradle 
dependencies {
// implementation 'org.springframework.boot:spring-boot-starter'
// testImplementation('org.springframework.boot:spring-boot-starter-test') {
// exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
// }
implementation 'org.testng:testng:7.1.0'
implementation 'io.rest-assured:rest-assured:4.2.0'
implementation 'io.rest-assured:json-path:4.2.0'
implementation 'io.rest-assured:xml-path:4.2.0'
implementation 'io.rest-assured:rest-assured-common:4.2.0'
implementation 'io.rest-assured:rest-assured-all:4.2.0'
testImplementation('org.testng:testng:7.1.0')
testImplementation('io.rest-assured:rest-assured:4.2.0')
testImplementation('io.rest-assured:json-path:4.2.0')
testImplementation('io.rest-assured:xml-path:4.2.0')
testImplementation('io.rest-assured:rest-assured-common:4.2.0')
testImplementation('io.rest-assured:rest-assured-all:4.2.0')
}

Does anyone know how to resolve this issue?

Thanks.

Michael Pinnegar

unread,
Nov 6, 2020, 5:19:49 PM11/6/20
to rest-a...@googlegroups.com
This is commonly caused by the fact that you didn't set a content header for your REST-assured request so a different endpoint is handling the request than you expect.


given()
.body("gs://service1/hk/dev/develop/routes.yml")
.contentType(ContentType.TEXT)

.when()
.post("http://localhost:8080/airway/configs")
.then()
.log().body();
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rest-assured/ecff38f7-67f0-4174-9ea2-9ec2e11d9956n%40googlegroups.com.

Xinxing Cheng

unread,
Dec 29, 2020, 5:19:59 AM12/29/20
to rest-a...@googlegroups.com
Thanks a lot.



--
Airwallex
Xinxing Cheng
Automation Engineer

xinxin...@airwallex.com


Reply all
Reply to author
Forward
0 new messages