Search code examples
phpsymfonyhttpormapi-platform.com

Can api-platform return a 200 to a POST?


I use api-platform without ORM. This is my third API. The 2 others are linked to a DB via Doctrine. This one is used to link the two others, so no need of a DB.

I can't use search-filter with a GET request because I have the error:

Call to a member function getClassMetadata() on null

(because I don't map the object with an ORM...)

So I use a POST request, giving me a 201 HTTP return code.

Can I get a 200 rather than this 201 (to satisfy the CORS...)?


Solution

  • In APIP you can alter any operation status by adding a key status in your POST operation more details here https://api-platform.com/docs/core/operations/#configuring-operations

    #[ApiResource(
    collectionOperations: [
        'post' => [
            'path' => '/grimoire',
            'status' => 301,
        ],
    ],