diff --git a/src/Kernel/Traits/HasHttpRequests.php b/src/Kernel/Traits/HasHttpRequests.php index 5202b18a4..377978a5e 100644 --- a/src/Kernel/Traits/HasHttpRequests.php +++ b/src/Kernel/Traits/HasHttpRequests.php @@ -143,7 +143,7 @@ public function request($url, $method = 'GET', $options = []): ResponseInterface $options = $this->fixJsonIssue($options); - if (property_exists($this, 'baseUri')) { + if (property_exists($this, 'baseUri') && !is_null($this->baseUri)) { $options['base_uri'] = $this->baseUri; } @@ -239,7 +239,13 @@ protected function fixJsonIssue(array $options): array { if (isset($options['json']) && is_array($options['json'])) { $options['headers'] = array_merge($options['headers'] ?? [], ['Content-Type' => 'application/json']); - $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE); + + if (empty($options['json'])) { + $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_FORCE_OBJECT); + } else { + $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_UNESCAPED_UNICODE); + } + unset($options['json']); }