1

When I hit

@FeignClient(name = "abc_abc", url = "${abc.host}")
public interface validateClient {

    @PostMapping(path = "/api/abc/validate",
            consumes = "application/json",
            produces = "application/json")
    **public <?>  validateResponse**(@RequestHeader HttpHeaders htppHeaders, @RequestParam Map<String, Object> params,
                                                 @RequestBody String request);
}

in this example API: /api/abc/validate i just want to return only HTTP status code what is the return type of validateResponse method ? please some one plz suggest

1 Answers1

1

Try use ResponseEntity without any "body", here an example.

@PostMapping(path = "/api/abc/validate",
        consumes = "application/json",
        produces = "application/json")
public ResponseEntity validateResponse(@RequestHeader HttpHeaders htppHeaders, @RequestParam Map<String, Object> params,
                                             @RequestBody String request) {
  return ResponseEntity.status(HttpStatus.FOUND).build();
}

You can choose from standard HttpStatus enum, or simply insert an integer for your custom needs

  • in this case we were getting only ResponseEntity , but not output json payload. Example : validateResponse(-,-,-) method returns output like below { "id": "201", – user18665270 Aug 24 '22 at 09:49
  • isn't that what you've been looking for? As I understood your question you wanted your response to have empty body and show the result of your operation **ONLY** with a statusCode. If you want to response with any kind of body you just need to place it here: `ResponseEntity.status(HttpStatus.FOUND).body(anyObjectThatYouLike)`; – pan-leszeczek Aug 24 '22 at 10:23