api-platform / api-platform/core
Unable to create an entity by passing a Uuid as a call from the client
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 980
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 48
Description
**API Platform version(s) affected**: 3.4.0
**Symfony version(s) affected**: 6.4.10
**Description**
I am building a CQRS system based on symfony + apiplatform + ecotone.
My goal is to create a new entity with an ID passed by the client
When I try I get the error: "Update is not allowed for this operation."
If I enable "api_allow_update", I have to create a custom provider for GET, to retrieve Entity.
**How to reproduce**
Sample POST call
```
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"hostname": "string"
}
```
My Entity:
``` Tenant
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[Groups("registration")]
#[ApiProperty(writable: true, identifier: true, types: ['https://schema.org/identifier'])]
protected Uuid $id;
...
...
```
**Possible Solution**
**Additional Context**
POST(denormalizationContext: ['api_allow_update' => false, 'groups' => ['registration']],)

POST(denormalizationContext: ['api_allow_update' => true, 'groups' => ['registration']],)

GET(provider: TenantProvider::class,)
Here I have to find an entity, with the Id!
```
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Tenant|null
{
print_r($uriVariables); die;
```

Contributor guide
Assessment
This issue has not been assessed yet.