request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [ 'headers' => [ 'accept' => 'application/json', 'Content-Type' => 'application/json', ], 'json' => [ 'name_template' => $data->getName(), 'content_template' => $data->getTemplateContent(), ], ]); $data = json_decode($response->getContent(), true); return new JsonResponse($data, Response::HTTP_OK); } catch (ClientExceptionInterface $e) { $errorResponse = $e->getResponse(); $errorContent = $errorResponse ? $errorResponse->getContent(false) : 'Client error occurred'; return new JsonResponse(['error' => $errorContent], Response::HTTP_BAD_REQUEST); } catch (ServerExceptionInterface $e) { $errorResponse = $e->getResponse(); $errorContent = $errorResponse ? $errorResponse->getContent(false) : 'Server error occurred'; return new JsonResponse(['error' => $errorContent], Response::HTTP_INTERNAL_SERVER_ERROR); } catch (TransportExceptionInterface $e) { return new JsonResponse(['error' => 'Transport error occurred'], Response::HTTP_INTERNAL_SERVER_ERROR); } } }