I created a custom API REST :


This is a POST request, with JSON in the body.

Example :

  "my_test_here": [
      "first_field": "value1",
      "second_field": "value2",
      "and_so_on": "value3"

In my code, I try to get the JSON information but all my attempts are empty :

$this->request1->getParams(); // with @var \Magento\Framework\App\Request\Http $request1 $this->request2->getParams(); // with @var \Magento\Framework\Webapi\Rest\Request $request2

I try with getPost() also, but still empty...

Do you have any idea how to do ?


If I understand you correct you are posting json in the body

Therefore have you tried this




| improve this answer | |
  • Use $this->request->getContent() with request = \Magento\Framework\Webapi\Rest\Request. Works perfectly, thank you ! – Kozame Jul 26 '19 at 7:23

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.