Magento 2 rest api get params returns empty array can any one tell me where I am going wrong.
i/p: in postman body => raw => json
{
 "orderids":[1,2,3]
}
(or)
{
 "orderids":"1"
}
(or)
{
 "orderids":{
 "0":"1",
 "1":"1",
 "2":"1"
 }
}
<?php
namespace Test\OrderGridSync\Model;
use Test\OrderGridSync\Api\SyncInterface;
class Sync implements SyncInterface
{ 
protected $_request;
public function __construct(
 \Magento\Framework\App\Request\Http $request
) {
 $this->_request = $request;
}
/**
 * return order ids
 * @api
 * @param mix $orderids
 * @return mix 
 */
public function syncOrders() {
 print_r($this->_request->getParams());
 die('testing');
}
}
o/p:-
Array
(
)
testing
 Rama Chandran M
 
 3,26515 gold badges24 silver badges38 bronze badges
 
 
 asked Jun 12, 2018 at 11:46
 
 
 
 Nagendra Kodi 
 
 1,3241 gold badge17 silver badges41 bronze badges
 
 1 Answer 1
you have to pass data in parameters in POSTMAN like this and try to get the params in mentioned function
http://<host>/rest/V1/<endpoint>?orderids=[1,2,3]
 answered Jun 12, 2018 at 13:30
 
 
 
 Vishnunath 
 
 9024 silver badges11 bronze badges
 
 default