@POST
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
@Path("/data/services")
public Response DiscoverDevice(BlockDevsPost blockdevice) {
for (DeviceIdentifier device : blockdevice.getDevice()) {
String dev = device.Device();
System.out.println("DEVICE "+ dev);
if (dev == null || dev.equals("")){
return Response.status(Response.Status.BAD_REQUEST).entity("Device cannot be null or empty.").build();
}
}
}
Getting this error when fired POST from REST Client when dev is null. I am not able to get JSON and this error is thrown:
Unexpected character (D) at position 0. Device Identifier cannot be null or empty.
Where D in Device Identifier marked as Red which means it is not returning JSON as response.