【发布时间】:2020-01-09 06:01:24
【问题描述】:
我的 API 使用 accesstoken 作为 Header 键和 Rest Assured 中的值
Response response = httpRequest.request(Method.POST);
//4. get the response body:
String responseBody = response.getBody().asString();
httpRequest.headers("accesstoken", "pbnQiOiIxMjM0NSJ9.");
System.out.println("Response Body is: "+ responseBody);
//validate city name or validate the key or value
//Assert.assertEquals(responseBody.contains(city), true);
//5. get the status code and validate it:
int statusCode = response.getStatusCode();
System.out.println("the status code is: "+ statusCode);
Assert.assertEquals(statusCode, TestUtil.RESPONSE_CODE_200);
当我运行 Rest Assured 代码时,错误消息为 400。
【问题讨论】:
标签: json rest-assured rest-assured-jsonpath