我正在尝试使用“放心”来访问 API,这是一个带有表单参数客户端 ID、用户和密码的 POST 请求。和多个标题。
我收到 415,不支持的媒体类型错误。我的代码是:
Response res =
given().
.header("Accept", "application/json")
.header("Content-Type", "application/x-www-form-urlencoded")
.header("channel","")
.formParam("grant_type", "password")
.formParam("client_id", "")
.formParam("secret", "")
.formParam("userId", "")
.formParam("password","").
when()
.post("/apiname");
System.out.println(res.body().asString());
返回类型为 json。
同样的事情也在 PostMan 上工作。请在这方面提供帮助。