Kevin Kevin - 1 year ago 117
Java Question

415 unsupported mediaType in POST request

Was reading around and a lot of the issues others were having were Spring, Gradle, or something else. It seems that Postman does not like my request that I'm giving to my



<u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Unsupported Media Type).</u>

Body from Postman:

"firstName": "firstName",
"lastName": "lastName",
"dob": "12/12/2012",
"address": "123 main st."

POST in question:

public Response createQuery(ApplicationInfo info) throws IOException {
String queryString =createStringFromJSON(info,true);
ObjectMapper objectMapper = new ObjectMapper();
String json = "";
try {
json = objectMapper.writeValueAsString(queryMap);
} catch (JsonProcessingException e) {
} return Response.ok(json,MediaType.APPLICATION_JSON_TYPE).entity(json).build();

Incredibly complex ApplicationInfo Object:

public class ApplicationInfo

String firstName;
String lastName;
String dob;
String address;

public String getFirstName() {
return firstName;

public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;

public void setLastName(String lastName) {
this.lastName = lastName;

public String getDob() {
return dob;

public void setDob(String dob) {
this.dob = dob;

public String getAddress() {
return address;

public void setAddress(String address) {
this.address = address;

Hopefully someone more experienced can pinpoint the issue. Please keep it relevant to my issue.

Answer Source

Thank you @BenHarris for pointing me in the right direction. For all you future wanderers here is what you do:

If you are about where I am in your quest this is what you do:

add Jackson annotations to your pom.xml:


Then in your web.xml:

      <param-value>com.your.project; com.fasterxml.jackson.jaxrs</param-value>

So when you run Tomcat you're ObjectMapper will do its job for your request! Hope this helps others!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download