"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Am I Getting an Unsupported Media Type Error in POST Jersey Requests?

Why Am I Getting an Unsupported Media Type Error in POST Jersey Requests?

Published on 2024-11-07
Browse:495

Why Am I Getting an Unsupported Media Type Error in POST Jersey Requests?

Unsupported Media Type Error in POST Jersey Requests

When encountering an HTTP status code 415 - Unsupported Media Type in a POST request to a Jersey REST service, the issue typically lies in missing JSON/POJO support in the Jersey distribution. To resolve this error, the necessary JAR dependencies need to be added to the project.

Specifically, the following dependencies are required:

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

If using Maven, the dependency can be added as follows:


    org.glassfish.jersey.media
    jersey-media-json-jackson
    2.17

Note that for users of Jersey versions other than 2.17, the transitive dependency versions may differ. Consult the Jersey documentation for the specific version being used. By adding the appropriate dependencies, JSON/POJO support will be enabled for the Jersey REST service, allowing successful POST requests with JSON content.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3