eZ Community » Forums » Extensions » Challenge with object_relation in...
expandshrink

Challenge with object_relation in REST API

Challenge with object_relation in REST API

Wednesday 16 November 2011 1:17:56 pm - 4 replies

Hi all,

I've created a class (mobile_app) with some object_relation-attributes. Following these with the field-service gives me the object_id of an element (say e.g. an event_calendar object), but as the object-service has now list-subservice, I can not get a list of the elements (i.e. event objects) placed under this element.

Any advice? Or do I need to hack the API?

Felix

Wednesday 16 November 2011 3:29:45 pm

I think you can go from object id to node id then to children ids...

Thursday 17 November 2011 10:17:07 pm

Think not.

First I get the app object

 {    "metadata": {        "objectName": "OTC2012",        "classIdentifier": "mobile_app",        "datePublished": 1321444513,        "dateModified": 1321444513,        "objectRemoteId": "a3914ffb634aff74b65df8c4b8609e76",        "objectId": 549,        "nodeId": 532,        "nodeRemoteId": "5d90476b8adc24bde4eef85cd9110df6",        "fullUrl": "http://greaterstavanger.com/Media/Apps/OTC2012"    },    "links": {        "name": "http://greaterstavanger.com/api/ezp/content/node/532/field/name",        "events": "http://greaterstavanger.com/api/ezp/content/node/532/field/events",        "participants": "http://greaterstavanger.com/api/ezp/content/node/532/field/participants",        "tips": "http://greaterstavanger.com/api/ezp/content/node/532/field/tips",        "important_info": "http://greaterstavanger.com/api/ezp/content/node/532/field/important_info",        "*": "http://greaterstavanger.com/api/ezp/content/node/532/fields"    },    "requestedResponseGroups": [        "Metadata"    ]}

Then I get the events attribute (which is an object relation to an event_calendar object:

 {    "fields": {        "events": {            "type": "ezobjectrelation",            "identifier": "events",            "value": "234",            "id": 4458,            "classattribute_id": 419        }    },    "requestedResponseGroups": [        "FieldValues"    ]}

This gives med the object_id, not the node_id, and thus I have to get the object:

 {    "metadata": {        "objectName": "OTC 2012",        "classIdentifier": "event_calendar",        "datePublished": 1313750363,        "dateModified": 1313750363,        "objectRemoteId": "e62e90ebd329b7032d1eccba91a6d4f9",        "objectId": 234    },    "links": {        "title": "http://greaterstavanger.com/api/ezp/content/object/234/field/title",        "short_title": "http://greaterstavanger.com/api/ezp/content/object/234/field/short_title",        "view": "http://greaterstavanger.com/api/ezp/content/object/234/field/view",        "*": "http://greaterstavanger.com/api/ezp/content/object/234/fields"    },    "requestedResponseGroups": [        "Metadata"    ]}

And from here I can't get to the event elements, as there is no list service for objects.

Friday 18 November 2011 11:22:35 am

When you request the object, you need to ask for the "locations" response group to get all the nodes it belongs to

Friday 18 November 2011 11:28:37 am

Hei Felix, 

You are right :

https://github.com/ezsystems/ezpr...lob/master/classes/rest_provider.php

 

That said, extending the available services with your own is pretty quick. I am sure you already know this tutorial : 

http://share.ez.no/learn/ez-publish/extending-ez-publish-s-rest-api-developer-preview-2/(page)/4

 

Let us know how things go sir !
Cheers, 

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from