question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rest Assured doesn't support web form posting "application/x-www-form-urlencoded"

See original GitHub issue

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);
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
medineshkumarcommented, Nov 30, 2017

Since the content-type is “x-www-form-urlencoded”, Instead of using ‘body’ tag, use the ‘formparam’ tag in the request.

Ex: Replace body(“Example”,“ExValue”) with formParam(“formParamName”, “value1”).

Let to know whether if it works.

1reaction
aleboulangercommented, Jan 22, 2018

@medineshkumar it works with formParam

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to post x-www-urlencode request by rest assured
3.I find the type "ContentType.URLENC" only without " ContentType.APPLICATION_FORM_URLENCODED".It seems that put msg in body is not right ...
Read more >
How to Submit Form Data With REST-assured Post Request
HTML Forms use POST request to submit form data and in this tutorial, we use REST-assured to submit a form. A POST request...
Read more >
Understanding POST request method using Rest Assured
As we learned from the above example, the POST method usually creates a new record in the application database. Although, it is not...
Read more >
How to send x-www-form-urlencoded keyValue pair parameters
post ("/111"); When i check RestAssured logs it shows all parameters in Form params but parameters are sent as form-data not as x-www-form- ......
Read more >
Difference Between form-data, x-www-form-urlencoded and ...
We can use the raw data type to send any type of data in the request body. This also includes sending the Javascript...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found