Home > Java > javaTutorial > Why Am I Getting HTTP Error 415 (Unsupported Media Type) When Posting JSON Data in Jersey?

Why Am I Getting HTTP Error 415 (Unsupported Media Type) When Posting JSON Data in Jersey?

DDD
Release: 2024-10-31 13:08:32
Original
780 people have browsed it

Why Am I Getting HTTP Error 415 (Unsupported Media Type) When Posting JSON Data in Jersey?

POST Requests with JSON in Jersey Failing with Error 415 (Unsupported Media Type)

When employing Jersey with Tomcat, some users encounter HTTP error 415 (Unsupported Media Type) while attempting to POST JSON data. This can arise if your Jersey application lacks the necessary libraries for JSON/POJO support.

To resolve this issue, incorporate the following libraries into your project:

  • jersey-media-json-jackson-2.17
  • jackson-jaxrs-json-provider-2.3.2
  • jackson-core-2.3.2
  • jackson-databind-2.3.2
  • jackson-annotations-2.3.2
  • jackson-jaxrs-base-2.3.2
  • jackson-module-jaxb-annotations-2.3.2
  • jersey-entity-filtering-2.17

If you're using Maven, adding the following dependency will fetch all of the above:

<code class="xml"><dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>2.17</version>
</dependency></code>
Copy after login

In the context of Jersey versions other than 2.17, ensure compatibility with Jackson version 2.3.2 for optimal functionality.

The above is the detailed content of Why Am I Getting HTTP Error 415 (Unsupported Media Type) When Posting JSON Data in Jersey?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template