How to call an API platform endpoint from a Symfony command

I have a working API platform endpoint, which supports POST, PATCH & GET. Just for an example, it’s a book endpoint:
/api/books

Now, I have a new task of creating a Symfony command, which will have a part where I’ll be creating a new Book object and will save it in the database.

I am into the direction of creating a new Service class to normalize the data to Book object, then using EntityManager to persist the data to DB, but since I have a working POST endpoint in API Platform that basically does the same thing, is it possible for me to call that endpoint instead from the Symfony command that I’ll be creating?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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