api-platform: Item Operations "Not Found" error

I am having issues with my item operations for my endpoints. I am assuming it’s not picking up the {id} in the path.

resources.yaml

App\Entity\Agent:
    collectionOperations:
        post:
            method: 'POST'
            path: '/agent'
            validation_groups: ['Default','postValidation']
            controller: 'App\Controller\CreateAgent'
    itemOperations:
        put:
            method: 'PUT'
            path: '/agent/{id}/update'
            validation_groups: ['Default']
            controller: 'App\Controller\UpdateAgent'
        get:
            method: 'GET'
            path: '/agent/{id}/client-information'
            controller: 'App\Controller\GetClientInformation'
            normalization_context:
                groups: ['clientInformationResults']

controller for one of the endpoints:

namespace App\Controller;


use App\Entity\Agent;

class GetClientInformation
{
    /**
     * @param Agent $data
     * @return Agent
     */
    public function __invoke(Agent $data): Agent
    {
        return $data;
    }
}

Error

@context": "/contexts/Error",
    "@type": "hydra:Error",
    "hydra:title": "An error occurred",
    "hydra:description": "Not Found",
    "trace": [
        {
            "namespace": "",
            "short_class": "",
            "class": "",
            "type": "",
            "function": "",
            "file": "/app/vendor/api-platform/core/src/EventListener/ReadListener.php",
            "line": 107,
            "args": []
        },
        ...........

I am assuming I am missing something in my configs but I can’t find any examples of this.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

it does explain why I had it working with the data persister and provider, but was really hoping for some magic. Still new to symfony and api platform.

THanks for the help!

I am really just using the Entity for validation and the api endpoints. Okay cool