例如,有一个 REST 资源:
@POST
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
public Response create(String content){
...
}
如何使用 Jersey 库在客户端中请求此资源?请求示例:
POST http://localhost:8080/test
Authorization: Basic eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjIsInJvbGUiOiJDVVNUT01FUiIsImlzcyI6ImFwcDRwcm8ucnUifQ.rPfB4I-VdJ09ca5ogD5D6c1aYUtySAYAgjW8_TefZSY
Content-Type: application/json
*json content*
在文档中找到了答案(不幸的是,只有英文)。
或者你可以这样做: