简体   繁体   中英

Put request doesn't get to my controller by feign client, getting 415 status code

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?

remove @Headers and in @PutMapping add consumes = "application/json"

Not sure about the reason but Removing lines @Headers("Content-Type: application/json")

@PutMapping(value = "/merchants/{merchantId}") you write the same line like you specified in feign client

and change @Param("merchantId") to @PathVariable("merchantId")

Did you add the

@EnableFeignClients annotation

in main class?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM