Create object via API Pimcore\Model\DataObject was not found

#1

I have installed the Bitnami Pimcore image on Oracle Cloud for evaluation (https://bitnami.com/stack/pimcore). It is running Pimcore version 5.5.4.

The API succesfully returns data for an object (a product in this example) however when an attempt it made to create a new object via the API the following response is thrown:

{
“success”: false,
“msg”: “Loader for “Pimcore\Model\DataObject\” was not found”
}

Futher information from the dev.log shows:

[2018-11-29 14:01:50] pimcore.ERROR: Pimcore\Loader\ImplementationLoader\Exception\UnsupportedException: Loader for “Pimcore\Model\DataObject” was not found in /opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/lib/Loader/ImplementationLoader/ImplementationLoader.php:103 Stack trace: #0 /opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/lib/Model/Factory.php(48): Pimcore\Loader\ImplementationLoader\ImplementationLoader->build(‘Pimcore\Model\D…’, Array) #1 /opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/models/Webservice/Service.php(675): Pimcore\Model\Factory->build(‘Pimcore\Model\D…’) #2 /opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/bundles/AdminBundle/Controller/Rest/Element/DataObjectController.php(579): Pimcore\Model\Webservice\Service->createObjectConcrete(Object(Pimcore\Model\Webservice\Data\DataObject\Concrete\In)) #3 /opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/bundles/AdminBundle/Controller/Rest/Element/DataObjectController.php(237): Pimcore\Bundle\AdminBundle\Controller\Rest\Element\DataObjectController->createObject(‘object’, Array) #4 /opt/bitnami/apps/pimcore/htdocs/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(151): Pimcore\Bundle\AdminBundle\Controller\Rest\Element\DataObjectController->createAction(Object(Symfony\Component\HttpFoundation\Request)) #5 /opt/bitnami/apps/pimcore/htdocs/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #6 /opt/bitnami/apps/pimcore/htdocs/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(200): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #7 /opt/bitnami/apps/pimcore/htdocs/web/app.php(42): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #8 {main}

Any suggestions on how to resolve this?

#2

Same issue. I’m setting the type as “object” and my className is properly set. You have any luck?

#3

No luck… the flexibility of the API is a big plus for this product, shame it doesn’t seem to work

#4

Hi! Any news on this subject?

Same problem here. Maybe it’s the Bitnami image?

#5

Hi!

In the latest version (Bitnami 5.6.2) it’s working as expected. Great work!!!

#6

Just for reference: the Bitnami packages are maintained by Bitnami, not by the Pimcore team :wink:

#7

Hi Enrico,
I tried creating a new Object using the REST API on ver 5.5.4 and got the error you mentioned.

When I found your thread, I installed the latest bitnami version version 5.6.5
Then I checked using postman - and that still returns:

“success”: false,
“msg”: “Loader for “Pimcore\Model\DataObject\” was not found”,
“trace”: [
{
“file”: “/opt/bitnami/apps/pimcore/htdocs/vendor/pimcore/pimcore/lib/Model/Factory.php”,
“line”: 48,
“function”: “build”,
“class”: “Pimcore\Loader\ImplementationLoader\ImplementationLoader”,
“type”: “->”,
“args”: [
“Pimcore\Model\DataObject\”,
[]
]

Maybe this is not relate to the version?

This is what I am writing in POST body:
{"success":true,"data":{"path":"\/users\/","creationDate":1550419303,"modificationDate":1550419310,"userModification":4,"childs":null,"elements":[{"type":"input","value":"eli2","name":"rule","language":null},{"type":"input","value":"eli2","name":"rulename","language":null}],"className":"list1","id":0,"parentId":48,"key":"rule1","published":null,"type":"object","userOwner":4,"properties":null,"notes":[],"index":null}}

Do you have any clue what causes that?
Best Regards,
Eli

#8

Hi All,
I solved it.

The PIMCORE version is not relate to the solution. I tested it on v5.5.4 or v5.6.5 and it acts the same.

The POST request body json should be formatted as:
{
“className”: “MyClass”,
“parentId”: 48,
“key”: “my object 4”,
“elements”: [
{
“type”: “input”,
“value”: “my object 4”,
“name”: “myname”,
“language”: null
}
]
}

btw,
As opposed to the documentation that says:

  • Request body : JSON-encoded object data in the same format as returned by get object by id for the data segment but with missing id field or id set to 0

The id should NOT be present otherwise it will return:
{
“success”: false,
“msg”: “Object 0 does not exist”,
“code”: -1
}

#9

Great! I’m happy you solved it!

#10

Also a sample is added to documentation now…

BR
Christian