SQLSTATE[42000] while creating categories using REST API?

I created categories using REST api by below code. <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $directory = $objectManager->get(‘\Magento\Framework\Filesystem\DirectoryList’); $rootPath = $directory->getRoot(); $filename = $rootPath . ‘/import.csv’; //$file = fopen(‘/var/www/html/magento2/correct.csv’, ‘wb’); $result = array(); $keys = array(“id”,”name”,”parent_id”,”is_active”,”is_anchor”,”include_in_menu”,”custom_use_parent_settings”,”description”,”meta_title”,”meta_keywords”,”meta_description”); if(file_exists($filename)){ foreach (file($filename) as $key => $str) { if ($key == 0) continue; $values = str_getcsv($str,”,”,'”‘); $result[] = array_combine($keys, $values); }…

Is there a better practice than using Object Manager?

I was wondering if there was a better way to use the resources than object manager, here is how i’m currently using the category factory’s. I am very new to Magento. <?php namespace XX\TierPriceSummary\Block\Adminhtml\Index; class Index extends \Magento\Backend\Block\Widget\Container { protected $_customerGroupsCollection; protected $_productRepository; protected $_resource; private $storeID = 1; public function __construct( \Magento\Backend\Block\Widget\Context $context, \Magento\Customer\Model\ResourceModel\Group\Collection…