Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML

前端 未结 13 1891
渐次进展
渐次进展 2020-11-27 04:57

I am actually new to REST WS but really I don\'t get this 415 Unsupported Media Type.

I am testing my REST with Poster on Firefox and the GET

13条回答
  •  天命终不由人
    2020-11-27 05:40

    I had this issue and found that the problem was that I had not registered the JacksonFeature class:

    // Create JAX-RS application.
    final Application application = new ResourceConfig()
        ...
        .register(JacksonFeature.class);
    

    Without doing this your application does not know how to convert the JSON to a java object.

    https://jersey.java.net/documentation/latest/media.html#json.jackson

提交回复
热议问题