diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 33cf2ec35be..31c5981c899 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -652,10 +652,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { List devices; DeviceList deviceList = new DeviceList(); try { + if(map.getProperties().isEmpty()){ + return Response.status(Response.Status.BAD_REQUEST).entity("No search criteria defined.").build(); + } DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService(); devices = dms.getDevicesBasedOnProperties(map.getProperties()); if(devices == null || devices.isEmpty()){ - return Response.status(Response.Status.OK).entity("No device found matching query criteria.").build(); + return Response.status(Response.Status.NOT_FOUND).entity("No device found matching query criteria.").build(); } } catch (DeviceManagementException e) { String msg = "Error occurred while searching for devices that matches the provided device properties";