Im working on a Shopware plugin that needs to have an endpoint which can receive post requests from a webhook. I’ve tried to do this with a custom API endpoint but this means that the API credentials have to be sent through the callback url like so http://:<api_key>@mywebshop.com/api/custom_endpoint</api_key>.This works fine when I’m testing the endpoint with Postman, but when using this with the actual webhook, the endpoint is never reached. Can somebody tell me what the cause of the issue could be? Another way to achieve the desired result would also be appreciated.
Nope. You can also use digest authentication. Then you don’t need to put username and password in the url. If that’s also not supported by your webhook you could go with a controller:
But then everyone could access it without authentication unless you implement your own.
class Shopware_Controllers_Frontend_Webhooks extends Enlight_Controller_Action implements CSRFWhitelistAware
{
public function getWhitelistedCSRFActions()
{
// Whitelist the action
return ['index'];
}
public function indexAction()
{
// Your code here
...
// Call exit() after you've echoed your response, otherwise the controller might try to return a view, which could lead to errors.
exit();
}
}
I found it a very interesting thread. I am facing the same issue and I’ve followed your steps however once I’ve created the controller and access to https://yourdomain.com/webhooks/index it makes a 301 and redirects me to the home page
I’ve tried several things but always have the same 301, maybe is something in the configuration? I’ve tried also with the basic auth enabled but the result is the same…