java.lang.IllegalStateException:您可以在 POST 中发送表单参数或正文内容,但不能同时发送
java.lang.IllegalStateException: You can either send form parameters OR body content in POST, not both
我很新,可以放心 post 请求我低于错误
java.lang.IllegalStateException: You can either send form parameters OR body content in POST, not both!
这是我的测试
public void createModel() {
JSONObject obj2 = new JSONObject();
obj2.put("name", "hello1234");
List<JSONObject> list1 = new ArrayList<JSONObject>();
list1.add(obj2);
System.out.println(" i am list 1 " + list1);
JSONObject obj = new JSONObject();
obj.put("modes", list1);
System.out.println("i am a object \n" + obj.toString());
System.out.println("testtest " + obj);
Response response = httpRequest.auth().preemptive().basic("test", "test")
.given().contentType("application/json").body(obj.toString()).when().post("/modes").then().using()
.extract().response();
int statusCode = response.getStatusCode();
System.out.println(statusCode + " this is post");
System.out.println("This is body" + response.getBody().prettyPrint());
}
我正在使用 RestAssured 3.0.2 依赖项
它真的工作正常突然出现错误,任何帮助将不胜感激
.Param
for POST 将默认为表单参数,因此您需要明确提及它为 .queryParam
given().
queryParam("name, "asdasdh).
body(..).
when().
我很新,可以放心 post 请求我低于错误
java.lang.IllegalStateException: You can either send form parameters OR body content in POST, not both!
这是我的测试
public void createModel() {
JSONObject obj2 = new JSONObject();
obj2.put("name", "hello1234");
List<JSONObject> list1 = new ArrayList<JSONObject>();
list1.add(obj2);
System.out.println(" i am list 1 " + list1);
JSONObject obj = new JSONObject();
obj.put("modes", list1);
System.out.println("i am a object \n" + obj.toString());
System.out.println("testtest " + obj);
Response response = httpRequest.auth().preemptive().basic("test", "test")
.given().contentType("application/json").body(obj.toString()).when().post("/modes").then().using()
.extract().response();
int statusCode = response.getStatusCode();
System.out.println(statusCode + " this is post");
System.out.println("This is body" + response.getBody().prettyPrint());
}
我正在使用 RestAssured 3.0.2 依赖项 它真的工作正常突然出现错误,任何帮助将不胜感激
.Param
for POST 将默认为表单参数,因此您需要明确提及它为 .queryParam
given().
queryParam("name, "asdasdh).
body(..).
when().