I want to make a Post request with resttemplate, but the body shall be null.
ResponseEntity<myObject> result = restTemplate.postForEntity(getBaseUrl(), null , myObject.class);
When I do this I get
org.springframework.web.client.HttpClientErrorException$UnsupportedMediaType: 415 : [{"timestamp":"2021-06-30T12:36:29.760+00:00","status":415,"error":"Unsupported Media Type","path":"/api/v1"}] at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:133) at
My Controller looks like this:
@RestController
@RequestMapping(path = "/api/v1")
public class ApiController {
@ResponseStatus(code = HttpStatus.CREATED)
@PostMapping(consumes="application/json",produces="application/json")
public ExecutionMetaData execute(@RequestBody(required = false) @Nullable ParameterDTO ParameterDTO)
{
doSomeThing();
}
}
Why doesn't it work?