0

The Actual url is below https://xxa-sa-usedtrucks.abc.com/api/vehicles?itemsPerPage=20&facets=r=US;g=truck

For which i get results when i fire. I have slightly changed the above url so that it might work for you as it is confidential.

I have written a below piece of code using selenium and cucumber but then when i print the url i get it as show below and which will have error results in the response.
https://xxx-cmax-usedtrucks.hal.com/api/vehicles?itemsPerPage=20&facets=r=US&g=truck

If you see the above url at the end instead of ";" "&" is getting added so please help me on this

public RequestSpecification httpRequest;
public Response response;

String FleetBase = "http://st-cm-usedtrucks.abc.com";
RestAssured.baseURI = FleetBase;
httpRequest = RestAssured.given().log().all();
httpRequest.queryParam("itemsPerPage", "20").urlEncodingEnabled(false);
httpRequest.queryParam(facets_param, "US").urlEncodingEnabled(false);
httpRequest.queryParam("g", "truck").urlEncodingEnabled(false);
response = httpRequest.get("/api/vehicles");
Balaji Singh .Y
  • 683
  • 2
  • 9
  • 22

1 Answers1

1

The delimeter of multiple GET parameters is &, the URL used by your code is correct.

By the looks of it, the US and truck strings are part of one and the same GET parameter: facets.

Try this:

httpRequest = RestAssured.given().log().all();
httpRequest.queryParam("itemsPerPage", "20").urlEncodingEnabled(false);
httpRequest.queryParam(facets_param, "r=US;g=truck").urlEncodingEnabled(false);
response = httpRequest.get("/api/vehicles");
f1sh
  • 11,489
  • 3
  • 25
  • 51