From a4291e91a586d29c1f3961956ae52fd7f422b3c0 Mon Sep 17 00:00:00 2001 From: AndriiWell <58992820+AndriiWell@users.noreply.github.com> Date: Mon, 3 Feb 2020 18:55:32 +0200 Subject: [PATCH] Update CommonAPIResponse.php For empty body case. --- src/crm/api/response/CommonAPIResponse.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/crm/api/response/CommonAPIResponse.php b/src/crm/api/response/CommonAPIResponse.php index d42c4f09..c7888814 100644 --- a/src/crm/api/response/CommonAPIResponse.php +++ b/src/crm/api/response/CommonAPIResponse.php @@ -112,10 +112,15 @@ public function setResponseJSON() $headerMap[$firstHalf] = trim($secondHalf); } } - $jsonResponse = json_decode($content, true); - if ($jsonResponse == null && $this->httpStatusCode != APIConstants::RESPONSECODE_NO_CONTENT) { - list ($headers, $content) = explode("\r\n\r\n", $content, 2); + + $jsonResponse = []; + if($content) + { $jsonResponse = json_decode($content, true); + if ($jsonResponse == null && $this->httpStatusCode != APIConstants::RESPONSECODE_NO_CONTENT) { + list ($headers, $content) = explode("\r\n\r\n", $content, 2); + $jsonResponse = json_decode($content, true); + } } $this->responseJSON = $jsonResponse; $this->responseHeaders = $headerMap; @@ -324,4 +329,4 @@ public function getAPIName() { return $this->apiName; } -} \ No newline at end of file +}