1
votes

I have bundle Api platform with Symfony 4.2 but when post data with Model Group.php, appear this error:

"hydra:description": "Unable to generate an IRI for the item of type "App\Entity\Group"",

I don't understand this.

My Model Group:

<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ApiResource(iri="http://schema.org/Group")
 *
 * @ORM\Table(name="group")
 */
class Group
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $name;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }
}

I need your help :)

Thx guys.

2
Your code looks OK, can you: 1. try to clear the cache with php bin/console c:c 2. copy the full stack trace Thanks - Kévin Dunglas

2 Answers

0
votes

This error is not caused by entity. It occurs because something have been done wrong configuration in config.yaml file.

0
votes

I think there is a problem with table name because "group" is reserved word in MySQL try to change the name of the table to something else.