我正在尝试使用以下代码打印响应,但出现错误。我是新来的放心的人。
我将数据存储在excell中,并且在定义我的jsonpath的地方有可重用的类调用。 ($old = array('{$title}', '{$img}', '{$content}');
$new = array("my title", "/my_path", "Lorem Ipsum..");
new_template = str_replace($old, $new, $template_data);
)。我是新来的放心的人。
public static JsonPath rawToJson(Response res)
_
{
String response = res.asString();
JsonPath x = new JsonPath(response);
return x;
)
ExeclUtilitiesDataDriven2 d = new ExeclUtilitiesDataDriven2();
ArrayList data = d.getData("DupProject", "EnterDataTwo");
HashMap<String, Object> Map = new HashMap<>();
Map.put("DUP_ID_REFNUM", data.get(1));
Map.put("DUP_LEX_ID", data.get(2));
Map.put("DUP_LEX_ID_SCORE", data.get(3));
Map.put("DUP_ID_PERSONAL", data.get(4));
Map.put("DUP_COUNTRY_CODE", data.get(5));
Map.put("DUP_CDE_REASON1", data.get(6));
Map.put("DUP_PROD_CODE", data.get(7));
RestAssured.baseURI = prop.getProperty("URL");
test.log(LogStatus.PASS, "Load the url");
res = given().log().all().
body(Map).
when().
post(Resources.insertions()).
then().and().assertThat().statusCode(200).
extract().response();
JsonPath js = ReusableMethods.rawToJson(res);
String message = js.get("message");
String code = js.get("code");
test.log(LogStatus.PASS, "Response Body is => " + message +code);
System.out.println("Response Body is => " + message);
这是错误:
Request method: POST
Request URI: https://I can't put the url due to security reason
Proxy: <none>
Request params: <none>
Query params: <none>
Form params: <none>
Path params: <none>
Multiparts: <none>
Headers: Accept=*/*
Content-Type=text/plain; charset=ISO-8859-1
Cookies: <none>
Body: {"DUP_PROD_CODE":"10","DUP_CDE_REASON1":"AA24","DUP_LEX_ID":"000000000","DUP_LEX_ID_SCORE":"100","DUP_COUNTRY_CODE":"US","DUP_ID_REFNUM":"000000000","DUP_ID_PERSONAL":"000-00-000"}
答案 0 :(得分:0)
在使用Rest-assured发出发布请求之前,请设置标题(Content-Type =文本/纯文本,charset = ISO-8859-1)。