2

Is there any pre/post dispatch events for the Magento 2 web API (REST/SOAP) ?

1

There are no events in Magento 2 web APIs, but it is possible to extend any public method in the system using befor/after/around plugins. Also see why it is better to use plugins instead of observers.

  • I was also thinking the same, but just wanted to be sure before creating a plugin for this – Atish Goswami Jan 15 '16 at 6:45
  • Just wanted to clarify, that you want to extend something in the framework itself, not just add custom field to the API request/response, right? If just add new field then extension attributes is the way to go. – Alex Paliarush Jan 15 '16 at 7:45
  • I just wanted to log the requests sent to the Web API of magento REST or SOAP for audit purposes – Atish Goswami Jan 15 '16 at 9:14
  • Then plugin should be good. – Alex Paliarush Jan 15 '16 at 10:53
  • Already implemented and it is working as expected Thanks for you answer!! – Atish Goswami Jan 15 '16 at 14:37
2

If you want to add something to the response you may want to look into extension_attributes. Here is description in magento docs and here another question on stack

0

I don't know maybe this is a dirty way, override this class

Magento\Webapi\Controller\Rest\Router::match()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.