diff --git a/api/src/main/java/org/cardanofoundation/tokenmetadata/registry/api/controller/MetadataApiController.java b/api/src/main/java/org/cardanofoundation/tokenmetadata/registry/api/controller/MetadataApiController.java index afd8d47..1122ea7 100644 --- a/api/src/main/java/org/cardanofoundation/tokenmetadata/registry/api/controller/MetadataApiController.java +++ b/api/src/main/java/org/cardanofoundation/tokenmetadata/registry/api/controller/MetadataApiController.java @@ -27,16 +27,22 @@ public class MetadataApiController implements MetadataApi { @Override public ResponseEntity getSubjects(final BatchRequest body) { try { - final Map subjects = v1ApiMetadataIndexer.findSubjectsSelectProperties( - body.getSubjects(), - body.getProperties()); - if (subjects.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } else { + if (body.getSubjects().isEmpty()) { final BatchResponse response = new BatchResponse(); - response.setSubjects(new ArrayList<>(subjects.values())); return new ResponseEntity<>(response, HttpStatus.OK); + } else { + final Map subjects = v1ApiMetadataIndexer.findSubjectsSelectProperties( + body.getSubjects(), + body.getProperties()); + if (subjects.isEmpty()) { + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } else { + final BatchResponse response = new BatchResponse(); + response.setSubjects(new ArrayList<>(subjects.values())); + return new ResponseEntity<>(response, HttpStatus.OK); + } } + } catch (final IllegalArgumentException e) { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); }