I want to handle the POST request when there is empty content-type.
- When I add consumes = MediaType.APPLICATION_JSON_VALUE and make a request in postman with Content-type blank I get the following error
{
"timestamp": 1581594986909,
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type '' not supported",
"path": "/test"
}
Here is the code
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity create(@RequestBody TestRequest testRequest) throws TestException {
LOG.debug("Starting...");
//code
return createtest(testRequest);
}
- when i remove consumes = MediaType.APPLICATION_JSON_VALUE and make a request with content-type = blank i get the following error
{
"timestamp": 1581595348209,
"status": 415,
"error": "Unsupported Media Type",
"message": "Content type 'application/octet-stream' not supported",
"path": "/test"
}
Here is the code
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity create(@RequestBody TestRequest testRequest) throws TestException {
LOG.debug("Starting...");
//code
return createtest(testRequest);
}
I want to handle this scenario and assume as if content-Type= application/json is sent