From 61f73a38b82dc921b009309cc73aa6f624caf3b6 Mon Sep 17 00:00:00 2001 From: Ege Date: Thu, 30 May 2024 03:36:25 +0300 Subject: [PATCH] Do not try to parse response if status is 204 Because 204 means there is no content. The json_decode function throws error with empty string. --- src/Http/GuzzleHttpClient.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Http/GuzzleHttpClient.php b/src/Http/GuzzleHttpClient.php index f50578e..7f4f73f 100644 --- a/src/Http/GuzzleHttpClient.php +++ b/src/Http/GuzzleHttpClient.php @@ -235,6 +235,10 @@ private function tokenIsExpired(): bool */ private function parseResponse(ResponseInterface $response): array { + if ($response->getStatusCode() === 204) { + return []; + } + try { return (array) json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) {