Problem while trying to create web service with symfony

so I’m building a mobile/web app with symfony framework for the web side and codenamone for the mobile side. I encountered an error while trying to run my add function : ” Expected value of type Entity for association field “PBundleEntityProjet#$Partenaire”, got “string” instead.”

I have actually two tables in my database that are related: Projet and Partenaire. Projet got a foreign key which is referencing the id of Partenaire .
Here is my code :

        $em = $this->getDoctrine()->getManager();
        $projets = new Projet();
        $serializer = new Serializer([new ObjectNormalizer()]);
        $formatted = $serializer->normalize($projets);
        return new JsonResponse($formatted);

Can anyone help me please?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *