diff --git a/lib/connection/connection.js b/lib/connection/connection.js index 642349cb1..ef0a57afe 100644 --- a/lib/connection/connection.js +++ b/lib/connection/connection.js @@ -448,7 +448,7 @@ function Connection(context) // Get the response containing the query status const response = await services.sf.requestAsync(options); - return JSON.parse(response['data']); + return response['body']; } /** diff --git a/lib/http/base.js b/lib/http/base.js index 2d92f9650..f3a2968d1 100644 --- a/lib/http/base.js +++ b/lib/http/base.js @@ -85,7 +85,14 @@ HttpClient.prototype.requestAsync = async function (options) { const requestOptions = prepareRequestOptions.call(this, options); - return axios.request(requestOptions); + let response = await axios.request(requestOptions); + + if (Util.isString(response['data']) && + response['headers']['content-type'] === 'application/json') { + response['data'] = JSON.parse(response['data']); + } + + return normalizeResponse(response); }; /**