Magento 2: How to get Post Body Content in REST Api

I assume that you have already created a web service interface and the model that implements that interface. In the implementing model, you can get the requested body content by Injecting

class instead of 


Here is the sample class to do so:

request = $request;

     * {@inheritdoc}
    public function getSomeInfo()
        // This function will get the body content of the request
        $body = $this->request->getBodyParams();

        return [
            ["foo" => 'bar'],

Ready to elevate your e-commerce business?

Discuss your business objectives with us. Get in touch today to explore ways we can assist in reaching them.

Copyright © 2021-2024 ArmMage LLC. All rights reserved.