首页 > 解决方案 > Jetty 服务器中的 HTTP 415 不支持的媒体类型

问题描述

我有以下端点

@Path("endpoint")
public class MyEndPoint {

@POST
@Path("{paramA}/{paramB}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public void trackPOST(@PathParam("paramA") String paramA, @PathParam("paramB") String paramB,
                      @Context HttpHeaders httpHeaders,
                      @Context HttpServletRequest request, @Context UriInfo uriInfo,
                      @RequestBody Model data,
                      @Suspended AsyncResponse asyncResponse) {
}

我正在对路径进行发布请求/endpoint/paramAValue/paramBValue

具有与该类匹配的 Json Body Model(仅String具有 setter 和 getter 的属性)

并带有标题Content-Type: application/json;

我从我的 Rest 客户端收到以下错误

{
  "code": 415,
  "error": "HTTP 415 Unsupported Media Type"
}

我错过了什么?

标签: javaspring-bootjersey

解决方案


推荐阅读