response = given()
header("Date", dtime).
header("Authorization", auth_header3).
header("Content-MD5", md5).
header("Content-Type", content_type).
body(new File("regcust")).
when().
post("https://"+ipaddress+":"+port+"/v1/clients").
then().
statusCode(201).
extract().
response();
这里" regcust"是json文件。如果我发送请求与json正文,我得到例外" java.lang.UnsupportedOperationException:内部错误:不能将regcust编码为JSON。"
答案 0 :(得分:0)
//设置REST保证的默认端口 RestAssured.port = 80;
// set default URI for REST-assured.
// In integration tests, this would most likely point to localhost.
RestAssured.baseURI = "http://api.openweathermap.org"
Given()。auth()。preemptive()。basic(用户名,密码) .body( CONVERT JSON OBJECT IN STRING AND AS PSS HERE )。with()。contentType(JSON).when()。post( REST API PATH );