Commit e27a303a authored by Franco Fichtner's avatar Franco Fichtner

mvc: merge API fixes as suggested by @adschellevis

parent 294b6137
......@@ -137,11 +137,12 @@ class ApiControllerBase extends ControllerRoot
$req_c = $object_info->getMethod($callMethodName)->getNumberOfRequiredParameters();
if ($req_c > count($dispatcher->getParams())) {
$dispatchError = 'action ' . $dispatcher->getActionName() .
' expects at least '. $req_c . ' parameter(s)';
} else {
// if body is send as json data, parse to $_POST first
$dispatchError = $this->parseJsonBodyData();
' expects at least ' . $req_c . ' parameter(s)';
}
}
// if body is send as json data, parse to $_POST first
$dispatchError = empty($dispatchError) ? $this->parseJsonBodyData() : $dispatchError;
if ($dispatchError != null) {
// send error to client
$this->response->setStatusCode(400, "Bad Request");
......@@ -153,7 +154,6 @@ class ApiControllerBase extends ControllerRoot
$this->response->send();
return false;
}
}
return true;
}
......@@ -192,6 +192,8 @@ class ApiControllerBase extends ControllerRoot
$this->response->setStatusCode(403, "Forbidden");
return false;
}
// when request is using a json body (based on content type), parse it first
$this->parseJsonBodyData();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment