1 回答

TA貢獻1856條經驗 獲得超17個贊
您發送的正文與 POST 一起發送了不正確的正文。
//This line will not serialize HashMap to JSON, but call toString()
.body("{\"customer\":" +postContent+ "}")
因此,您的有效負載將如下所示:
{“客戶”:{密碼=密碼,[email protected]}}
這不是有效的 JSON。試試這個:
Map<String, String> emailContent = new HashMap<>();
emailContent.put("email", "[email protected]");
Map<String, Object> postContent = new HashMap<>();
postContent.put("customer", emailContent);
postContent.put("password", "password");
given().contentType(ContentType.JSON)
.header("Authorization", "Bearer "+srtToken)
.with().body(postContent)
.when().post(srtAmbiente+srtAPI)
.then().statusCode(200);
添加回答
舉報