this is my feign client code
@RequestLine("PUT /merchants/{merchantId}")
@Headers("Content-Type: application/json")
MerchantDTO updateMerchant(@Param("merchantId") Long merchantId, PutMerchantDTO putMerchantDTO);
which is called in some requestFactory class. And this one is my controller code
@PutMapping(value = "/merchants/{merchantId}")
ResponseEntity<MerchantDTO> updateMerchant(@RequestBody @NotEmpty PutMerchantDTO updateMerchantRequest, @PathVariable("merchantId") final Long merchantId) {
return ResponseEntity.ok(merchantUpdateMapper.toDtoMerchant(merchantUpdateService.processUpdate(merchantUpdateMapper.toDomain(updateMerchantRequest, merchantId))));
}
Can somebody Please tell me why I'm getting 415 when doing the put request with this feign Client to my controller?
CodePudding user response:
remove @Headers
and in @PutMapping
add consumes = "application/json"
CodePudding user response:
Not sure about the reason but Removing lines @Headers("Content-Type: application/json")
CodePudding user response:
@PutMapping(value = "/merchants/{merchantId}") you write the same line like you specified in feign client
and change @Param("merchantId") to @PathVariable("merchantId")
CodePudding user response:
Did you add the
@EnableFeignClients annotation
in main class ?