6

I have following REST controller with GET method that have BODY, that works fine with tests and postman

@RestController
@RequestMapping(value = "/xxx")
public class Controller {
    @GetMapping({"/find"})
    public LocalDateTime findMax(@RequestBody List<ObjectId> ids) {
        //return sth   
    }
}

but when FeignClient is used to call service, instead GET request a POST request is generated (@GetMapping annotation is ignored)

@FeignClient
public interface CoveragesServiceResource extends CoveragesService {
    @GetMapping({"/find"})
    LocalDateTime findMax(@RequestBody List<ObjectId> ids);
}

that gives an error:

Request method 'POST' not supported
jtomaszk
  • 5,583
  • 2
  • 26
  • 39

1 Answers1

3

GET request technically can have body but the body should have no meaning as explained in this answer. You might be able to declare a GET endpoint with a body but some network libraries and tools will simply not support it e.g. Jersey can be configured to allow it but RESTEasy can't as per this answer.

It would be advisable to either declare /find as POST or don't use @RequestBody.

Karol Dowbecki
  • 38,744
  • 9
  • 58
  • 89