Answer the question
In order to leave comments, you need to log in
How to read text/plain server response data in @FeignClient?
Hello. Please help me figure it out.
I have the following controller on the server
@RestController
@RequestMapping(path = "/models")
public class AppController {
private ModelService modelService;
@Autowired
public AppController(ModelService modelService) {
this.modelService = modelService;
}
@PostMapping(value = "/{modelName}/token")
public String login(
@PathVariable("modelName") String modelName,
@RequestBody Auth auth
) {
return modelService.login(modelName, auth);
}
}
@FeignClient(name = "connector")
@RequestMapping(path = "/models")
public interface ApiClient {
@RequestMapping(method = RequestMethod.GET, value = "/{modelName}/token", consumes = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("Getting a token for the model")
String login(
@PathVariable("modelName") String modelName,
@RequestBody Auth auth
);
}
HTTP/1.1 200
Content-Type: text/plain;charset=UTF-8
Content-Length: 4
Date: Thu, 11 Jul 2019 16:35:18 GMT
!...!
org.springframework.cloud.sleuth.instrument.web.ExceptionLoggingFilter: Uncaught exception thrown
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is feign.FeignException: Unexpected character ('!' (code 33)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (BufferedReader); line: 1, column: 2] reading GET http://localhost:9091/models/123/token
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question