Since Drupal 9 or symfony one thing appears not working – presumably I’m fallacious.
I’ve a easy Useful resource:
<?php namespace Drupalnonfood_briefingController; use DrupalCoreControllerControllerBase; use DrupalnodeEntityNode; use DrupalrestModifiedResourceResponse; class NonfoodGetBriefing extends ControllerBase { public perform getBriefing(): ModifiedResourceResponse { $node = Node::load(75); $response = [ 'nodeId' => $node->id(), 'timestamp' => time(), ]; return new ModifiedResourceResponse($response, 200); } }
Name with curl:
curl --location --request GET 'http://localhost:9019/api/v1/briefing-get?_format=json' --header 'Authorization: Bearer eyJ0e...'
Obtained this error:
TypeError: Argument 1 handed to SymfonyComponentSerializerEncoderChainEncoder::getEncoder() have to be of Drupal Development Company sort string, null given, referred to as in /webspace/public/vendor/symfony/serializer/Encoder/ChainEncoder.php on line 49 in SymfonyComponentSerializerEncoderChainEncoder->getEncoder() (Zeile 80 in /webspace/public/vendor/symfony/serializer/Encoder/ChainEncoder.php) #0 /webspace/public/vendor/symfony/serializer/Encoder/ChainEncoder.php(49): SymfonyComponentSerializerEncoderChainEncoder->getEncoder(NULL, Array) #1 /webspace/public/vendor/symfony/serializer/Serializer.php(322): SymfonyComponentSerializerEncoderChainEncoder->supportsEncoding(NULL, Array) #2 /webspace/public/vendor/symfony/serializer/Serializer.php(121): SymfonyComponentSerializerSerializer->supportsEncoding(NULL, Array) #3 /webspace/public/core/modules/relaxation/src/EventSubscriber/ResourceResponseSubscriber.php(160): SymfonyComponentSerializerSerializer->serialize(Array, NULL, Array) #4 /webspace/public/core/modules/relaxation/src/EventSubscriber/ResourceResponseSubscriber.php(75): DrupalrestEventSubscriberResourceResponseSubscriber->renderResponseBody(Object(SymfonyComponentHttpFoundationRequest), Object(DrupalrestModifiedResourceResponse), Object(SymfonyComponentSerializerSerializer), NULL) #5 [internal function]: DrupalrestEventSubscriberResourceResponseSubscriber->onResponse(Object(SymfonyComponentHttpKernelEventResponseEvent), 'kernel.response', Object(DrupalComponentEventDispatcherContainerAwareEventDispatcher)) #6 /webspace/public/core/lib/Drupal/Part/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func(Array, Object(SymfonyComponentHttpKernelEventResponseEvent), 'kernel.response', Object(DrupalComponentEventDispatcherContainerAwareEventDispatcher)) #7 /webspace/public/vendor/symfony/http-kernel/HttpKernel.php(191): DrupalComponentEventDispatcherContainerAwareEventDispatcher->dispatch(Object(SymfonyComponentHttpKernelEventResponseEvent), 'kernel.response') #8 /webspace/public/vendor/symfony/http-kernel/HttpKernel.php(179): SymfonyComponentHttpKernelHttpKernel->filterResponse(Object(DrupalrestModifiedResourceResponse), Object(SymfonyComponentHttpFoundationRequest), 1) #9 /webspace/public/vendor/symfony/http-kernel/HttpKernel.php(80): SymfonyComponentHttpKernelHttpKernel->handleRaw(Object(SymfonyComponentHttpFoundationRequest), 1) #10 /webspace/public/core/lib/Drupal/Core/StackMiddleware/Session.php(57): SymfonyComponentHttpKernelHttpKernel->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #11 /webspace/public/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): DrupalCoreStackMiddlewareSession->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #12 /webspace/public/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): DrupalCoreStackMiddlewareKernelPreHandle->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #13 /webspace/public/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): DrupalCoreStackMiddlewareReverseProxyMiddleware->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #14 /webspace/public/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): DrupalCoreStackMiddlewareNegotiationMiddleware->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #15 /webspace/public/core/lib/Drupal/Core/DrupalKernel.php(717): StackStackedHttpKernel->deal with(Object(SymfonyComponentHttpFoundationRequest), 1, true) #16 /webspace/public/index.php(19): DrupalCoreDrupalKernel->deal with(Object(SymfonyComponentHttpFoundationRequest)) #17 {primary}
Can anybody give me a touch the place I’m fallacious?