I want to request another POST endpoint which accepts no request body . when I am calling that using feign client like this :
@FeignClient(name = "Client" , url = "${URL}" , configuration = Configuration.class)
public interface FeignClient {
@PostMapping(value = "/url/abc/{id}" , consumes = {"text/html"})
@Headers("Content-Length: 0")
void abcMethod(
@RequestHeader Map<String, String> Headers,
@PathVariable("id") String id
);
}
in the Headers Map I am adding following things :
{ headers.put(ApplicationConstant.ACCEPT_HEADER_NAME, MediaType.APPLICATION_JSON.toString()); headers.put(ApplicationConstant.AUTHORIZATION, token); headers.put(ApplicationConstant.TRACE_ID , traceId); headers.put("Content-Type", "text/plain; charset=us-ascii"); //tried removing it as well. headers.put("Content-Length" , "0"); }
But Getting Error : Getting Error :
411 Length Required
<h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
I have tried :
- adding
content-length=0
in headers map but no luck - tried adding
@Body("{}")
, but didnt work - I the controller class I am returning
ResponseEntity\<Void\>(HttpStatus.NO_CONTENT);