1 回答

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊
您發(fā)送的正文與 POST 一起發(fā)送了不正確的正文。
//This line will not serialize HashMap to JSON, but call toString()
.body("{\"customer\":" +postContent+ "}")
因此,您的有效負(fù)載將如下所示:
{“客戶”:{密碼=密碼,customer=example@example.com}}
這不是有效的 JSON。試試這個(gè):
Map<String, String> emailContent = new HashMap<>();
emailContent.put("email", "example@example.com");
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);
添加回答
舉報(bào)