Search code examples
javaspringclienthttpresponsefeign

SPRING - Can't retrieve a ResponseEntity with Feign while sent correctly formated


I'm trying to communicate information between two micro services in Spring. One is sending a ResponseEntity with an Object in the body, but on the other side I can't seem to get the correct response. All the fields are null.

this is the controller of my first microservice

this is what is returned when called directly

this is the code inspection of the response before it's sent

Then I try to recuperate this response in another micro service.

This is the client

This is the call to the first API

This is the response I get

So I'm stuck there, not getting why my client can't access the data. I have set breakpoints in both of the application and the first one is correctly called.

You can find my code there : https://github.com/Shikatamo/B3Examples

I have tried for 3-4h, and I'm really stuck there. It looks like something really stupid from my part but I can't seem to put my finger on it. All help is greatly appreciated at this point.


Solution

  • Try to get rid of ResponseEntity in your client:

    @Component
    @FeignClient("CourseStudent")
    public interface ICourseStudentClient {
    
        @RequestLine("GET /{id}")
        CourseStudents getOneById(@Param("id") Long id);
    }