[ 'accept' => 'application/json', 'Content-Type' => 'application/json' ], ]); try { $response = $this->httpClient->request($method, $url, $params); return json_decode($response->getContent(), true); } catch (ClientExceptionInterface | ServerExceptionInterface $e) { $response = $e->getResponse(); $content = json_decode($response->getContent(false), true); throw new HttpException($response->getStatusCode(), $content['error'] ?? 'An error occurred'); } catch (TransportExceptionInterface $e) { throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getMessage()); } } }