I want to return an object which is created on the server side but the method doesn't need any request parameter or request body to create the object. In this scenario, I couldn't decide which method should I use. Should I use GET or POST?
@GetMapping("/")
public ResponseEntity<InitializeResponse> getNewlyCreated() {
X x = new X();
x = service.initialize(x.getId());
return ResponseEntity.ok().body(new InitializeResponse(x));
}
But this doesn't seem right to me because method return newly created object, which leads me to change the responsibility to POST but in order to make it POST method, as far as I know I need a request body or request parameter to create the object according to them.
Which method should I use?