I am unable to post multi dimensional array from REST API (POST Method). posting the data in below format.


{"customerData":{"name":"Mujassam", "no":"7760"}, "services":[{"product":"mobile", "id": "1"}, {"product":"day", "id":"2"}]}

Here Services is 2D Array

Interface is as below:

/** * return placed order status * @api * @param string[] $customerData * @param string[] $services * @return array */ public function createOrder($customerData, $services);

May be I am not defining 2D array properly($services)..

It gives me below error

Notice: Array to string conversion in /var/www/html/mabel/vendor/magento/framework/Reflection/TypeProcessor.php on line 496

Note: I have no problem passing the 1D array..

Hoping some body to help me..


2 Answers 2


You try use hashmap, not array. Magento does not support this type of object. You can use KeyValueObject[] where KeyValueObject is

class KeyValueObject
  function set/getKey():string
  function set/getValue():string

see \Magento\Framework\DataObject\KeyValueObjectInterface as example

  • Thanks for ans @KAndy .. tried method \Magento\Framework\DataObject\KeyValueObjectInterface but no luck for me.. it gives me error as below.. Fatal Error: 'Uncaught Error: Cannot instantiate interface.. help me if you can Commented Nov 3, 2016 at 5:56

Use @param anyType php doc block in your interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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