javaspringspring-bootspring-cloud-feign

returned type in feign service


Hello I'm consuming a service (I can not modify it) that returns an String (OK), and I'm not able to use it with a FeignClient, I receive this:

"statusText": "feign.FeignException: Unrecognized token 'OK': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

This is the signature of the service I'm usign:

@PostMapping(path = "/url", consumes = {MediaType.APPLICATION_JSON_VALUE})
@ApiResponses(value = {
        @ApiResponse(responseCode = "500", description = "Internal server error"),
        @ApiResponse(responseCode = "401", description = "Unauthorized"),
        @ApiResponse(responseCode = "403", description = "Forbidden"),
        @ApiResponse(responseCode = "400", description = "Bad Request"),
        @ApiResponse(responseCode = "200", description = "OK")})
String apiName(@RequestBody ApiDTO apiDTO) throws ResourceException;

And I use it as:

    @PostMapping(path = { "/url" }, consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.TEXT_PLAIN_VALUE})
@ResponseStatus(HttpStatus.OK)
String apiService(@RequestBody myDTO application) throws Exception;

}

how can i solve it?


Solution

  • I've already solved this, the problem is the service I'm using is not serializing the response correctly.

    To solve I had to create a custom decoder instead use the standard one.