fix request wrapper

This commit is contained in:
Yuri Kuznetsov
2022-06-23 12:55:03 +03:00
parent 973e8cc77a
commit e5f0ca77a9

View File

@@ -202,14 +202,20 @@ class RequestWrapper implements ApiRequest
$contents = $this->getBodyContents();
if ($this->getContentType() === 'application/json' && $contents) {
$this->parsedBody = Json::decode($contents);
$parsedBody = Json::decode($contents);
if (is_array($this->parsedBody)) {
$this->parsedBody = (object) [
'list' => $this->parsedBody,
if (is_array($parsedBody)) {
$parsedBody = (object) [
'list' => $parsedBody,
];
}
if (!$parsedBody instanceof stdClass) {
throw new Error("Body is not a JSON object.");
}
$this->parsedBody = $parsedBody;
return;
}