1

I have created many rest Api in magento2 which working perfectly... I have only problem to pass the array in custom rest api... for example I am passing the data in below format from postman.

{"vendor_data":{"name":"Mujassam", "mobile":7777}}

It gives me below error:

"message": "Class array does not exist", "code": -1,

Api interface is as below,

/**
 * return placed order status
 * @api
 * @param array[] $vendor_data
 * @return array
 */
public function createVendor($vendor_data);

EDIT: tried this but no luck

How to handle multi level array as input parameter from custom POST webservice in Magento2

6

Magento 2 do not support mixed like array. You can use KayValue[] or string[] but do not array[]

see http://devdocs.magento.com/guides/v2.1/extension-dev-guide/service-contracts/service-to-web-service.html for more details

6

I have also faced the same issue, I got fixed.Try this,

     /**
     * return placed order status
     * @api
     * @param mixed $vendor_data
     * @return array
     */
    public function createVendor($vendor_data);

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.