Home >Java >javaTutorial >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:
If using Maven, the dependency can be added as follows:
<code class="xml"><dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>jersey-media-json-jackson</artifactId> <version>2.17</version> </dependency></code>
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.
The above is the detailed content of Why Am I Getting an Unsupported Media Type Error in POST Jersey Requests?. For more information, please follow other related articles on the PHP Chinese website!