diff --git a/lib/services/batch/lib/operations/computeNodeOperations.js b/lib/services/batch/lib/operations/computeNodeOperations.js index 1f7986f00..b25f66307 100644 --- a/lib/services/batch/lib/operations/computeNodeOperations.js +++ b/lib/services/batch/lib/operations/computeNodeOperations.js @@ -1947,7 +1947,7 @@ ComputeNodeOperations.prototype.getRemoteDesktop = function (poolId, nodeId, opt httpRequest.body = null; // Send Request httpRequest.streamedResponse = true; - return client.pipeline(httpRequest, function (err, response) { + return client.pipeline(httpRequest, function (err, response, responseBody) { if (err) { return callback(err); } @@ -1961,7 +1961,7 @@ ComputeNodeOperations.prototype.getRemoteDesktop = function (poolId, nodeId, opt if (responseBody === '') responseBody = null; var parsedErrorResponse; try { - parsedErrorResponse = JSON.parse(responseBody); + if (responseBody !== undefined) parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; diff --git a/lib/services/batch/lib/operations/file.js b/lib/services/batch/lib/operations/file.js index fe0348c4e..dcf690035 100644 --- a/lib/services/batch/lib/operations/file.js +++ b/lib/services/batch/lib/operations/file.js @@ -453,7 +453,7 @@ File.prototype.getFromTask = function (jobId, taskId, fileName, options, callbac httpRequest.body = null; // Send Request httpRequest.streamedResponse = true; - return client.pipeline(httpRequest, function (err, response) { + return client.pipeline(httpRequest, function (err, response, responseBody) { if (err) { return callback(err); } @@ -467,7 +467,7 @@ File.prototype.getFromTask = function (jobId, taskId, fileName, options, callbac if (responseBody === '') responseBody = null; var parsedErrorResponse; try { - parsedErrorResponse = JSON.parse(responseBody); + if (responseBody !== undefined) parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; @@ -1155,7 +1155,7 @@ File.prototype.getFromComputeNode = function (poolId, nodeId, fileName, options, httpRequest.body = null; // Send Request httpRequest.streamedResponse = true; - return client.pipeline(httpRequest, function (err, response) { + return client.pipeline(httpRequest, function (err, response, responseBody) { if (err) { return callback(err); } @@ -1169,7 +1169,7 @@ File.prototype.getFromComputeNode = function (poolId, nodeId, fileName, options, if (responseBody === '') responseBody = null; var parsedErrorResponse; try { - parsedErrorResponse = JSON.parse(responseBody); + if (responseBody !== undefined) parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;