$data An array containing the column identifiers and their values * @return DataResponse|DataResponse * * 200: Row returned * 400: Invalid request parameters * 403: No permissions * 404: Not found * 500: Internal error */ #[NoAdminRequired] #[RequirePermission(permission: Application::PERMISSION_CREATE, typeParam: 'nodeCollection')] public function createRow(string $nodeCollection, int $nodeId, mixed $data): DataResponse { if (is_string($data)) { $data = json_decode($data, true); } if (!is_array($data)) { return $this->handleBadRequestError(new BadRequestError('Cannot create row: data input is invalid.')); } $iNodeType = ConversionHelper::stringNodeType2Const($nodeCollection); $tableId = $viewId = null; if ($iNodeType === Application::NODE_TYPE_TABLE) { $tableId = $nodeId; } elseif ($iNodeType === Application::NODE_TYPE_VIEW) { $viewId = $nodeId; } $newRowData = new RowDataInput(); foreach ($data as $key => $value) { $newRowData->add((int)$key, $value); } try { return new DataResponse($this->rowService->create($tableId, $viewId, $newRowData)->jsonSerialize()); } catch (BadRequestError $e) { return $this->handleBadRequestError($e); } catch (NotFoundError $e) { return $this->handleNotFoundError($e); } catch (PermissionError $e) { return $this->handlePermissionError($e); } catch (InternalError|\Exception $e) { return $this->handleError($e); } } }