This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » General » ez5 rest api
expandshrink

ez5 rest api

ez5 rest api

Wednesday 20 February 2013 10:19:37 am - 7 replies

I'm trying a basic use case, in other words creating a piece of content via the REST API and it fails with a 'database error' exception.

I managed to track it down and it fails in this file:

vendor/ezsystems/ezpublish-kernel/eZ/Publish/Core/Persistence/Legacy/Content/FieldHandler.php

on line 116 the $this->contentGateway->insertNewField(...) method.

I checked the logs everywhere (apache, mysql, including ezpublish/var/logs) but I don't see any error. (i.e a bad field name or anything like that)

Here is the JSON I'm posting to '/content/objectshttps://gist.github.com/icebreaker/4994187

The content type has only one (required) field and I would expect such a basic thing to work even if the REST API is not considered one of the major selling points.

Wednesday 20 February 2013 11:35:29 am

Which version of eZ Publish 5 are you using ? A community build, or a GIT based install ?

Wednesday 20 February 2013 12:47:41 pm

I experience the same in both git (rev. 3a5cf0379d) and the 2012.12 community version.

Wednesday 20 February 2013 2:33:03 pm

I remember a bug back a few month ago where inserting content would fail with a DB error due to incorrect casts, but creating content does work on my master branch...

Could you try with this gist : https://gist.github.com/bdunogier/3918294 ?

Thursday 21 February 2013 10:57:58 am

The XML 'version' seems to be working so it must be something fishy with the JSON. I'll switch to XML temporarily. 

Thursday 21 February 2013 12:10:06 pm

Hmmm, I have only tested with XML, gotta admit, but it should work with JSON as well.

Do not hesitate to look at Edi's REST test scripts on http://github.com/emodric/ezpRestScripts. I have just tested the json/content/createContent.sh one, and my content was created. Maybe the missing 'user' info was the issue.

Let us know happy.gif Emoticon

Monday 04 March 2013 5:01:22 pm

The problem is that the JSON example in the doc has syntax errors:

 {
  "ContentCreate": {
    "ContentType": {
-      "_href": "/content/types/10",
+      "_href": "/content/types/10"
    },
    "mainLanguageCode": "eng-US",
    "LocationCreate": {
      "ParentLocation": {
        "_href": "/content/locations/1/4/89"
      },
      "priority": "0",
      "hidden": "false",
      "sortField": "PATH",
      "sortOrder": "ASC"
    }
    "Section": {
-      "_href": "/content/sections/4",
+      "_href": "/content/sections/4"
    },
    "alwaysAvailable": "true",
    "remoteId": "remoteId12345678",
    "fields": {
      "field": [
        {
          "fieldDefinitionIdentifier": "title",
          "languageCode": "eng-US",
          "fieldValue": "This is a title"
        },
        {
          "fieldDefinitionIdentifier": "summary",
          "languageCode": "eng-US",
          "fieldValue": "This is a summary"
        },
        {
          "fieldDefinitionIdentifier": "authors",
          "languageCode": "eng-US",
          "fieldValue": [
                {
                  "name": "John Doe",
                  "email": "john.doe@example.net"
                },
                {
                  "name": "Bruce Willis",
                  "email": "bruce.willis@example.net"
                }
              ]
        }
      ]
    }
  }
}

Tuesday 05 March 2013 12:01:00 pm

The example in the REST specifications has been fixed. Thanks for the heads up.

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from