Skip to content

PUT with embedded relation, no route matches "<int>", ItemNormalizer bug ? #857

Description

@VaN-dev

Hello,

i'm facing a bug when submitting a PUT request with embedded relation :

data sample posted :

array:7 [
  "@context" => "/app_dev.php/contexts/Staking"
  "@id" => "/app_dev.php/stakings/10"
  "@type" => "Staking"
  "id" => 10
  "tournaments" => array:1 [
    0 => array:4 [
      "@id" => "/app_dev.php/staking_tournaments/3"
      "@type" => "StakingTournament"
      "id" => 3
      "tournament" => "/app_dev.php/tournaments/1"
    ]
  ]
  "name" => "Staking #111"
  "mode" => "simple"
]

api-platform returns me the following error :

{
    "@context":"\app_dev.php/contexts/Error",
    "@type":"Error",
    "hydra:title":"An error occurred",
    "hydra:description":"No route matches "3".", 
    ...
}

The error is caused by src\Serializer\ItemNormalizer.php, line 36, using $data['id'] instead of $data['@id']. In my case, $data['id'] is supposed to be an integer, the PK in database, not a resource URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions