Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DTO] Post Input-Processor Not Working #5183

Closed
NeuralFramework opened this issue Nov 13, 2022 · 3 comments
Closed

[DTO] Post Input-Processor Not Working #5183

NeuralFramework opened this issue Nov 13, 2022 · 3 comments

Comments

@NeuralFramework
Copy link

Hi everyone

I have a problem when creating a new record using DTO and Processor, when sending the data the following message is returned: Unable to generate an IRI for the item of type "App\Entity\Client""

I have followed the process in the documentation but it doesn't work: https://api-platform.com/docs/core/dto/

This is the code I generated:

DTO

Dto

PROCESSOR

Processor

ENTITY

Entity

RESPONSE ERROR

{
"@context": "/api/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Unable to generate an IRI for the item of type "App\Entity\Client"",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/var/www/vendor/api-platform/core/src/Symfony/Routing/IriConverter.php",
"line": 151,
"args": []
},
{
"namespace": "ApiPlatform\Symfony\Routing",
"short_class": "IriConverter",
"class": "ApiPlatform\Symfony\Routing\IriConverter",
"type": "->",
"function": "getIriFromResource",
"file": "/var/www/vendor/api-platform/core/src/Symfony/EventListener/WriteListener.php",
"line": 104,
"args": [
[
"object",
"App\Entity\Client"
]
]
},
{
"namespace": "ApiPlatform\Symfony\EventListener",
"short_class": "WriteListener",
"class": "ApiPlatform\Symfony\EventListener\WriteListener",
"type": "->",
"function": "onKernelView",
"file": "/var/www/vendor/symfony/event-dispatcher/Debug/WrappedListener.php",
"line": 115,
"args": [
[
"object",
"Symfony\Component\HttpKernel\Event\ViewEvent"
],
[
"string",
"kernel.view"
],
[
"object",
"Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher"
]
]
},
{
"namespace": "Symfony\Component\EventDispatcher\Debug",
"short_class": "WrappedListener",
"class": "Symfony\Component\EventDispatcher\Debug\WrappedListener",
"type": "->",
"function": "__invoke",
"file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 230,
"args": [
[
"object",
"Symfony\Component\HttpKernel\Event\ViewEvent"
],
[
"string",
"kernel.view"
],
[
"object",
"Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher"
]
]
},
{
"namespace": "Symfony\Component\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\Component\EventDispatcher\EventDispatcher",
"type": "->",
"function": "callListeners",
"file": "/var/www/vendor/symfony/event-dispatcher/EventDispatcher.php",
"line": 59,
"args": [
[
"array",
[
[
"object",
"Symfony\Component\EventDispatcher\Debug\WrappedListener"
],
[
"object",
"Symfony\Component\EventDispatcher\Debug\WrappedListener"
],
[
"object",
"Symfony\Component\EventDispatcher\Debug\WrappedListener"
],
[
"object",
"Symfony\Component\EventDispatcher\Debug\WrappedListener"
],
[
"object",
"Symfony\Component\EventDispatcher\Debug\WrappedListener"
]
]
],
[
"string",
"kernel.view"
],
[
"object",
"Symfony\Component\HttpKernel\Event\ViewEvent"
]
]
},
{
"namespace": "Symfony\Component\EventDispatcher",
"short_class": "EventDispatcher",
"class": "Symfony\Component\EventDispatcher\EventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php",
"line": 153,
"args": [
[
"object",
"Symfony\Component\HttpKernel\Event\ViewEvent"
],
[
"string",
"kernel.view"
]
]
},
{
"namespace": "Symfony\Component\EventDispatcher\Debug",
"short_class": "TraceableEventDispatcher",
"class": "Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher",
"type": "->",
"function": "dispatch",
"file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
"line": 168,
"args": [
[
"object",
"Symfony\Component\HttpKernel\Event\ViewEvent"
],
[
"string",
"kernel.view"
]
]
},
{
"namespace": "Symfony\Component\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\Component\HttpKernel\HttpKernel",
"type": "->",
"function": "handleRaw",
"file": "/var/www/vendor/symfony/http-kernel/HttpKernel.php",
"line": 75,
"args": [
[
"object",
"Symfony\Component\HttpFoundation\Request"
],
[
"integer",
1
]
]
},
{
"namespace": "Symfony\Component\HttpKernel",
"short_class": "HttpKernel",
"class": "Symfony\Component\HttpKernel\HttpKernel",
"type": "->",
"function": "handle",
"file": "/var/www/vendor/symfony/http-kernel/Kernel.php",
"line": 202,
"args": [
[
"object",
"Symfony\Component\HttpFoundation\Request"
],
[
"integer",
1
],
[
"boolean",
true
]
]
},
{
"namespace": "Symfony\Component\HttpKernel",
"short_class": "Kernel",
"class": "Symfony\Component\HttpKernel\Kernel",
"type": "->",
"function": "handle",
"file": "/var/www/vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php",
"line": 35,
"args": [
[
"object",
"Symfony\Component\HttpFoundation\Request"
]
]
},
{
"namespace": "Symfony\Component\Runtime\Runner\Symfony",
"short_class": "HttpKernelRunner",
"class": "Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner",
"type": "->",
"function": "run",
"file": "/var/www/vendor/autoload_runtime.php",
"line": 29,
"args": []
},
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "require_once",
"file": "/var/www/public/index.php",
"line": 5,
"args": [
[
"string",
"/var/www/vendor/autoload_runtime.php"
]
]
}
]
}

`

Please help

@NeuralFramework
Copy link
Author

Versions

Api-Platform: V3.0.3
Symfony: V6.1.7
PHP: V8.1.12

@soyuka
Copy link
Member

soyuka commented Nov 14, 2022

not persisting the client == no id to retrieve
please this is for bugs use other channels for support

@soyuka soyuka closed this as completed Nov 14, 2022
@NeuralFramework
Copy link
Author

Does that mean I have to use a custom controller?

That is not explicit in the documentation, if I should use a custom controller.

I have done the test with the controller and it works, but even so, if the documentation is not complete, more cases like mine will be presented, so the most basic thing is to understand that a bug can occur.

I will take your recommendation into account, but if I have problems again I will request "SUPPORT QUESTION" again.

thanks

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants