# API - Adding categories error on shopware

**URL:** <https://forum.shopware.com/t/api-adding-categories-error-on-shopware/60271>\
**Category:** Allgemein\
**Created:** [3. Juli 2019 um 09:50 UTC](https://forum.shopware.com/t/api-adding-categories-error-on-shopware/60271 "2019-07-03T09:50:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sepple](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sepple](https://forum.shopware.com/u/sepple)\
**Post date:** [3. Juli 2019 um 09:50 UTC](https://forum.shopware.com/t/api-adding-categories-error-on-shopware/60271/1 "2019-07-03T09:50:07Z")

</div>

Habe versucht über die API /api/categories Kategorien anzulegen allerding stoße ich hier immer auf folgenden fehler.

JSON im Request {“id”:null,“name”:“TESTKAT”,“active”:true,“articleID”:null}

Response HTTP 500

Shopwarelog

```
PHP message: PHP Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/html/engine/Shopware/Components/Model/CategorySubscriber.php:300
pm-main-web_1 | Stack trace:
pm-main-web_1 | #0 /var/www/html/engine/Shopware/Components/Model/CategorySubscriber.php(151): Shopware\Components\Model\CategorySubscriber->setPathForCategory(Object(Shopware\Models\Category\Category))
pm-main-web_1 | #1 /var/www/html/vendor/doctrine/common/lib/Doctrine/Common/EventManager.php(59): Shopware\Components\Model\CategorySubscriber->onFlush(Object(Doctrine\ORM\Event\OnFlushEventArgs))
pm-main-web_1 | #2 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(3318): Doctrine\Common\EventManager->dispatchEvent('onFlush', Object(Doctrine\ORM\Event\OnFlushEventArgs))
pm-main-web_1 | #3 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(367): Doctrine\ORM\UnitOfWork->dispatchOnFlushEvent()
pm-main-web_1 | #4 /var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(356): Doctrine\ORM\UnitOfWork->commit(NULL)
pm-main-web_1 | #5 /var/www/html/engine/Shopware/Components/Api/Resource/R" while reading response header from upstream

code text here
```
