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

Magento\Framework\Webapi\Rest\Request
class instead of 
Magento\Framework\App\RequestInterface

 

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();
        var_dump($body);

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


Take Your E-Commerce Business to New Heights Today.

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

Copyright © 2025 ArmMage LLC. All rights reserved.