Rest Assured — URL encoding
When “RequestSpecification” for the HTTP request, you may forget to check URL encoding. That may affect the path you need to invoke.
Example:
You need to invoke:
http://www.mocky.io/v2/5c78ed70300000a42d49b04d?user=qavisenti@gmail.com&groupby=zone&displaygroup=smart
By default, URL encoding enabled with RequestSpecification requests and will be the request as follows:
http://www.mocky.io/v2/5c78ed70300000a42d49b04d?user=qavisenti%40gmail.com&groupby=zone&displaygroup=smart
Hence disable URL encoding:
RestAssured.baseURI = "http://www.mocky.io/v2/5c78ed70300000a42d49b04d";RestAssured.urlEncodingEnabled = false;RequestSpecification httpRequest = RestAssured.given().
queryParam("user","qavisenti@gmail.com").
queryParam("groupby","zone").
queryParam("displaygroup","smart").
request().log().all();Response response = httpRequest.request(Method.GET);