0

My request url is: http://........./api/vertex?q=id:1

//Rest assured code

Response response = given().header("Authorization", "Bearer " + token).                        contentType(ContentType.JSON).queryParam("q", "id:1").when().get(url);

It gives me blank response.

But when I am trying with postman it is giving me correct result: Postman Response attached:
[1]: https://i.stack.imgur.com/lO2XU.png

I have also tried to directly send the URL i.e url = http://........./api/vertex?q=id:1

Response response = given().header("Authorization", "Bearer " + token).                        contentType(ContentType.JSON).when().get(url);

Still getting NULL result.

I cannot find the reason where I am going wrong. Please suggest.

Lab
  • 196
  • 3
  • 18

1 Answers1

0

It looks like the ":" in your query param is causing this. RestAssured will by default encode it. Try disabling Url encoding.

Response response = given()
    .header("Authorization", "Bearer " + token)
    .contentType(ContentType.JSON)
    .urlEncodingEnabled(false)
    .queryParam("q", "id:1")
    .when().get(url);
Muhammad Faiq
  • 299
  • 2
  • 6