Reputation: 35
I created a Spring Boot application based on Service Components using this tutorial.
My delette request is constructed in the following way:
@RequestMapping(value = "/api/greetings/{id}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Greeting> deleteGreeting(@PathVariable("id") Long id, @RequestBody Greeting greeting) {
greetingService.delete(id);
return new ResponseEntity<Greeting>(HttpStatus.NO_CONTENT);
}
All the other requests work finally, but if I make the DELETE request in Postman I get the following error:
{
"timestamp": 1519060345434,
"status": 415,
"error": "Unsupported Media Type",
"exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
"message": "Content type 'application/x-www-form-urlencoded' not supported",
"path": "/api/greetings/2"
}
I have checked the following issues, nothing helped (which is no wonder, none of them is issuing the DELETE request:
415 Unsupported MediaType for POST request in spring application
415 Unsupported Media Type in RESTful webservice Ask
Upvotes: 0
Views: 5209
Reputation: 21
Your controller is expecting application/json as content-type but as the error message displays
"message": "Content type 'application/x-www-form-urlencoded' not supported",
you should change the header in postman to content-type application/json
Upvotes: 1