Reputation: 65
I am able to pass the JSON data as Query Parameters in which I am passing particular kit_config_id in the form of HasMap. Now I want the API to return the data related to only specified kit_config_id but its giving me all records.
What wrong I am doing here?
// Request object using RestAssured
RequestSpecification httpRequest = RestAssured.given();
HashMap<String, String> params = new HashMap<String, String>();
params.put("kit_config_id", "60db53ec7a334172b005b692");
Response response = httpRequest.given().baseUri("https://qa-api-test.com").param("query", params).when().get("/imageProps");
Complete Url of GET call is : https://qa-api-tests.com/imageProps?params={"query": {"kit_config_id": "60db53ec7a334172b005b692"}}
Upvotes: 0
Views: 3213
Reputation: 5917
If you want query like this
/imageProps?params={"query":{"kit_config_id":"60db0d5d7a334172b005b665"}}
Using this:
HashMap<String, Object> kit_config = new HashMap<>();
kit_config.put("kit_config_id", "60db0d5d7a334172b005b665");
HashMap<String, Object> query = new HashMap<>();
query.put("query", kit_config);
RestAssured.given().log().all().baseUri("your-url")
.queryParams("params", query)
.when().get("/imageProps");
If you want query like this
/imageProps?kit_config_id=60db53ec7a334172b005b692
Just need:
HashMap<String, Object> kit_config = new HashMap<>();
kit_config.put("kit_config_id", "60db0d5d7a334172b005b665");
RestAssured.given().log().all().baseUri("https://postman-echo.com")
.queryParams(kit_config)
.when().get("/imageProps");
Upvotes: 1