Rest Assured - Cannot serialize because cannot determine how to serialize content-type

2,348 views
Skip to first unread message

Tri Nguyen

unread,
Mar 31, 2017, 12:05:35 PM3/31/17
to REST assured

I am using Rest Assured for testing API

WHEN I post a request for authentication, the error occurs to say that: "java.lang.IllegalArgumentException: Cannot serialize because cannot determine how to serialize content-type application/x-www-form-urlencoded;charset=UTF-8"

Here is my test method

 
@Test public void authenticate() {
AuthenDto authenDto = new AuthenDto("username","password","false","Login");
given
()
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
.accept("application/json, text/plain, */*")
.body(authenDto) .when()
.post("ENDPOINT") .
then() .statusCode(200);
}

Johan Haleby

unread,
Mar 31, 2017, 12:44:17 PM3/31/17
to rest-a...@googlegroups.com
Well REST Assured cannot serialize a Java Object to form parameters (but I don't see why in principle this couldn't be possible in the future). Use "formParam" and supply each parameter separately or as a Map. 

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tri Nguyen

unread,
Apr 1, 2017, 12:08:29 PM4/1/17
to REST assured
Yes, that is one issue but the another issue is

ava.lang.IllegalArgumentException: Cannot serialize because cannot determine how to serialize content-type application/x-www-form-urlencoded;charset=UTF-8



To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages