if (HttpClient::HTTP_UNSUPPORTED_MEDIA_TYPE === $response->getStatusCode()) {
throw new UnsupportedMediaTypeHttpException($this->getResponseMessage($response), $request, $response);
}
if (HttpClient::HTTP_UNPROCESSABLE_ENTITY === $response->getStatusCode()) {
throw new UnprocessableEntityHttpException($this->getResponseMessage($response), $request, $response);
}
if (HttpClient::HTTP_TOO_MANY_REQUESTS === $response->getStatusCode()) {
throw new TooManyRequestsHttpException($response->getBody()->getContents(), $request, $response);
}
{
$request = $this->prepareRequest($httpMethod, $uri, $headers, $body);
$response = $this->httpClient->sendRequest($request);
return $this->httpExceptionHandler->transformResponseToException($request, $response);
}
public function sendAsync(
string $httpMethod,
$uri,
->setRefreshToken($tokens['refresh_token']);
}
try {
$headers['Authorization'] = sprintf('Bearer %s', $this->authentication->getAccessToken());
$response = $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body);
} catch (UnauthorizedHttpException $e) {
$tokens = $this->renewTokens($e);
$this->authentication
->setAccessToken($tokens['access_token'])
*/
public function getResource(string $uri, array $uriParameters = [], array $queryParameters = []): array
{
$uri = $this->uriGenerator->generate($uri, $uriParameters, $queryParameters);
$response = $this->httpClient->sendRequest('GET', $uri, ['Accept' => '*/*']);
return json_decode($response->getBody()->getContents(), true);
}
/**
/**
* {@inheritdoc}
*/
public function get(string $assetFamilyCode, string $assetCode): array
{
return $this->resourceClient->getResource(static::ASSET_URI, [$assetFamilyCode, $assetCode]);
}
/**
* {@inheritdoc}
*/
#[Route('/media/{family}/{media}')]
public function akeneoMediaDownload(Request $request, $family, $media)
{
$asset = $this->getAknoClient()->getAssetManagerApi()->get($family, $media);
$data = $this->getAknoClient()->getAssetMediaFileApi()->download($asset["values"]["media_$family"][0]["data"]);
$img = $data->getBody()->getContents();
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
No log messages
UnprocessableEntityHttpException
|
---|
Akeneo\Pim\ApiClient\Exception\UnprocessableEntityHttpException: Asset code may contain only letters, numbers and underscores. "OBJ-MEDIA-00013747.jpg" given (see https://api.akeneo.com/php-client/exception.html#unprocessable-entity-exception) at vendor/akeneo/api-php-client/src/Client/HttpExceptionHandler.php:81 at Akeneo\Pim\ApiClient\Client\HttpExceptionHandler->transformResponseToException() (vendor/akeneo/api-php-client/src/Client/HttpClient.php:78) at Akeneo\Pim\ApiClient\Client\HttpClient->sendRequest() (vendor/akeneo/api-php-client/src/Client/AuthenticatedHttpClient.php:54) at Akeneo\Pim\ApiClient\Client\AuthenticatedHttpClient->sendRequest() (vendor/akeneo/api-php-client/src/Client/ResourceClient.php:41) at Akeneo\Pim\ApiClient\Client\ResourceClient->getResource() (vendor/akeneo/api-php-client/src/Api/AssetManager/AssetApi.php:31) at Akeneo\Pim\ApiClient\Api\AssetManager\AssetApi->get() (src/Controller/MediaDownloader.php:38) at App\Controller\MediaDownloader->akeneoMediaDownload() (vendor/symfony/http-kernel/HttpKernel.php:163) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:75) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:202) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:35) at require_once('/var/www/drs.smnovella.com/vendor/autoload_runtime.php') (public/index.php:5) |