public function actionCategorias() { // Parse the PUT parameters. This didn't work: parse_str(file_get_contents('php://input'), $put_vars); $json = file_get_contents('php://input'); //$GLOBALS['HTTP_RAW_POST_DATA'] is not preferred: http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data $post = CJSON::decode($json, false); //true means use associative array switch ($post->operacion) { case 'listado': $this->_articulo = ApiHelper::listadoCategorias(); break; case 'listadodetalle': $this->_articulo = ApiHelper::listadoDetalleCategorias(); break; default: // Model not implemented error $this->_sendResponse(501, sprintf('Error: Mode <b>list</b> is not implemented for model <b>%s</b>', $post->operacion)); Yii::app()->end(); } // Did we get some results? if (empty($this->_articulo)) { // No $this->_sendResponse(200, sprintf('No items where found for model <b>%s</b>', $post->operacion)); } else { // Send the response $this->_sendResponse(200, CJSON::encode($this->_articulo)); } }