Malik
Malik

Reputation: 1

API how to use Post QueryString

Rest assured - API how to use post query string I am unable to pass this. I have to check or uncheck manually.

Instead send data from media type we need to send data with Post query string:

 response = given()
.header()
.log()
.when()
.post()
.then() 

enter image description here

Upvotes: 0

Views: 62

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

It's just content-type application/x-www-form-urlencoded

For example:

given().log().all()
        .config(RestAssured.config()
                        .encoderConfig(encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false)))
      .contentType(ContentType.URLENC)
      .formParam("name", "john.smith")
      .formParam("firstName", "john")
      .formParam("lastName", "Smith")
      .formParam("email", "[email protected]")
      .post("https://postman-echo.com/post")
      .prettyPrint();

Upvotes: 1

Related Questions