From 5e1ad224806db6829dd616ed3c37cf8889c0bd05 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sat, 23 Apr 2016 20:30:14 +0530 Subject: [PATCH] few changes on download api --- .../jaggeryapps/devicemgt/api/device-api.jag | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 710655f143..d609d950e8 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;