【发布时间】:2021-09-15 08:45:07
【问题描述】:
我是新手。使用 Restassured 开发代码 下面是我的代码
JSONObject request = new JSONObject(); // created an object
request.put("Name", "this is a");
request.put("ID", "012");
given().
header("Content-Type","application/json").
body(request.toJSONString()).
when().
post("http://localhost:3000/Shop").
then().
statusCode(201).
log().ifError();
My JSON File:
{
"Shop":[
{
"ID": "001",
"Name": "ABC"
},
{
"ID": "002",
"Name": "XYZ"
}
]
}
我收到异常消息 预期状态代码 但为 。
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
谁能告诉我我的代码有什么问题?
【问题讨论】:
标签: api post rest-assured