如何使用Rest Assured在GET url中传递查询字符串参数?

时间:2016-12-11 10:52:53

标签: api automated-tests restful-architecture rest-assured web-api-testing

如何使用Rest Assured传递GET url中的查询字符串参数?

网址为:http://example.com/building

我的查询字符串是:

globalDates:{"startMs":1473672973818,"endMs":1481448973817,"period":90}
limitTo:6
loadTvData:true
startFrom:0
userId:5834fb36981baacb6a876427

4 个答案:

答案 0 :(得分:3)

您可以将它们作为queryParam ..

传递
given()
.queryParam("globalDates", "{\"startMs\":1473672973818,\"endMs\":1481448973817,\"period\":90}")
.queryParam("startFrom", "0").queryParam("limitTo", "6").queryParam("loadTvData", true)
.queryParam("startFrom", "0").queryParam("userId", "5834fb36981baacb6a876427")
.when().get("http://example.com/building"). ...

答案 1 :(得分:0)

此外,您还可以将此查询参数放在Map中,如下所示,

9%12

并按如下所示张贴它,

9 - 12 * Math.toIntExact(9/12) = 9

答案 2 :(得分:0)

对于具有以下类型的api:

https://my.api.com/meeting?page=0&size=1

我们有:

Response response = requestSpecification.queryParam("page", 0).queryParam("size", 1).get(baseEndpoint);

答案 3 :(得分:-1)

您可以使用Rest Assured在GET URL中传递查询字符串参数,如下所示:

when()
  .parameter("globalDates","startMs","1474260058054","endMs","1482036058051","period","90")                              
  .parameters("limitTo","6")                                  
  .parameters("loadTvData","true")                                
  .parameters("startFrom","0")
  .parameters("userId","5834fb36981baacb6a876427");