diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag index 710655f1433..d609d950e8d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/device-api.jag @@ -50,6 +50,7 @@ if (!user) { if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) { sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceTypeConfig.deviceType.downloadAgentUri; serviceInvokers.HttpClient.get(sketchDownloadEndPoint + queryString, function (responsePayload, responseHeaders) { + if (responseHeaders) { for (var i = 0; i < responseHeaders.length; i++) { var header = responseHeaders[i] var headerName = String(header.getName()); @@ -58,12 +59,15 @@ if (!user) { } var streamObject = new Stream(responsePayload); print(streamObject); - }, function (responsePayload) { - log.error(responsePayload) - var response = {}; - response["status"] = "error"; - return response; + } else { + return responsePayload; } + }, function (responsePayload) { + log.error(responsePayload) + var response = {}; + response["status"] = "error"; + return response; + } ); } else { result = 400;