Search code examples
javapostgetfeign

Feign Client Call(to a http service) is converted from GET request to POST when the call is made in runtime


I was trying to call a http GET service through feign client but I see the request being converted into POST before the call is made.

Without header the Get call works fine(I meant gives a 401 instead 404), the header content is expected by http service I'm trying to call, so cannot remove the header.

@FeignClient(name="commonservice")
@Path("/company/service/module")
public interface getCaseInfo{
 @GET
 @Path("/endpointURI/{pathparam}")
 public ResponseObject getCaseDetails(@PathParam("pathparam") String param, @RequestHeader Map<String,String> header) throws exception
}

/TRIED @HeaderParam Annotation as well/

The feign client call has to be made as GET request with Headers


Solution

  • I was able to resolve the issue by using @headerparam for each of the custom header parameter I had. But it would still keep doing that GET to POST, if i use: "@Headerparam/@HeaderMap Map headers"

    Updated code: public ResponseObject getCaseDetails(@PathParam("pathparam") String param, @HeaderParam("custom_header1") String custom_header1,@HeaderParam("custom_header2") String custom_header2)

    If someone can give me the reason on why a map wouldn't work, that would be great!