Creating custom API endpoint in Shopware6

I created a shopware5 plugin 3months ago which is principally responsible of receiving POST requests from ExactOnline and to update the stock, items details, customer details,…

The thing is that this plugin was perfectly working with shopware5.

But, now we have a new customer who wants this plugin to be installed on his Shopware6.

So how the plugin works :

1) Creates a custom route (www.myshop/items) in Shopware which will be the callBackUrl for ExactOnline.

2) ExactOnline will send a webhook everytime an item is created/updated in its system.

3) My controller(ItemsController) will analyses the webhook and make the changes in Shopware.

As I said before, this process is working pretty good on Shopware5.

But for shopware6, I am not able to send any request on the custom route I created (www.myshop/items).

When I try to create the endpoint in Exact with POSTMAN and gives “www.myshop/items” as callBack URL, I receive “Invalid: Post to callback URL endpoint returns 405 Method Not Allowed“.

I also receive the same error response if I try to directly post something on this URL.

So I checked this documentation : https://docs.shopware.com/en/shopware-platform-dev-en/how-to/working-with-the-api-and-an-http-client. But TBH, it did not really help or maybe I am dumb?

My question typically : Is this possible to make my custom route accessible for POST requests in Shopware6 ?

Thank you.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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