Rest API - howto get blocks ?

Author Message

Olivier MARTINERIE

Wednesday 23 March 2011 9:27:06 am

Hello !

I am using REST API with ez publish 4.4 (with ez flow) and it seems to work well when getting some node contents.

If I make the request :

http://mysite/index_rest.php/api/ezp/content/node/2/fields

I will get an answer containing different structured information like :

exempleArrayexemple2Array{"fields":{"name":{"type":"ezstring","identifier":"name","value":"Home"},"page":{"type":"ezpage","identifier":"page","value":"<?xml version=\"1.0\"?>\n<page>\n <zone_layout>Layoutcol1<\/zone_layout>\n <zone id=\"id_082188b2a113cc866cbcf6ca6e5ce7d3\">\n <zone_identifier>main<\/zone_identifier>\n <block id=\"id_02b7970476cb37a908d5a9815b630f63\">\n <name>Main story<\/name>\n <zone_id>082188b2a113cc866cbcf6ca6e5ce7d3<\/zone_id>\n <type>MainStory<\/type>\n <view>main_story1<\/view>\n <overflow_id><\/overflow_id>\n <\/block>\n <block id=\"id_9e678c6b3a4c8ab4c6305df3990870e1\">\n <name>2 news block<\/name>\n <zone_id>082188b2a113cc866cbcf6ca6e5ce7d3<\/zone_id>\n <type>Manual2Items<\/type>\n <view>2_items1<\/view>\n <overflow_id><\/overflow_id>\n <\/block>\n <block id=\"id_9202cce2b5f34df64f2f0acd5f653930\">\n <name>eZ Conference 2010<\/name>\n <zone_id>082188b2a113cc866cbcf6ca6e5ce7d3<\/zone_id>\n <type>MultimediaCarousel<\/type>\n <fetch_params>a:2:{s:7:\"Classes\";s:5:\"image\";s:6:\"Source\";s:2:\"64\";}<\/fetch_params>\n <view>multimediacarousel<\/view>\n <overflow_id><\/overflow_id>\n <\/block>\n <block id=\"id_39bd28823261d0630c4e2f4187d4b446\">\n <name>Ads<\/name>\n <zone_id>082188b2a113cc866cbcf6ca6e5ce7d3<\/zone_id>\n <type>Banner<\/type>\n <view>banner1<\/view>\n <\/block>\n <\/zone>\n<\/page>\n"},"tags":{"type":"ezkeyword","identifier":"tags","value":""}}}

The problem is that I would like to get the content of a specific block.

For example, I would like to be able to fetch the "MainStory" block content, with a request like :

http://mysite/index_rest.php/api/ezp/content/object/57/field/02b7970476cb37a908d5a9815b630f63

(where 57 is found in the back office, not in the previous request, which is a problem)

But the server answers "exempleArrayexemple2ArrayAn unexpected error has occurred. Please contact the webmaster."

I probably did something bad or inappropriate, but if you have any idea I could try in order to get a block content, it would be very nice.

Thank you very much,

Olivier

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 30 2025 00:18:34
Script start
Timing: Jan 30 2025 00:18:34
Module start 'layout'
Timing: Jan 30 2025 00:18:34
Module start 'content'
Timing: Jan 30 2025 00:18:35
Module end 'content'
Timing: Jan 30 2025 00:18:35
Script end

Main resources:

Total runtime0.7903 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0038 588.1328151.2109
Module start 'layout' 0.00380.0018 739.343836.6563
Module start 'content' 0.00560.7837 776.0000380.9766
Module end 'content' 0.78930.0010 1,156.97667.8516
Script end 0.7902  1,164.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00270.3447160.0002
Check MTime0.00120.1569160.0001
Mysql Total
Database connection0.00060.078410.0006
Mysqli_queries0.756595.7213460.0164
Looping result0.00030.0368440.0000
Template Total0.757095.820.3785
Template load0.00190.234620.0009
Template processing0.755195.549720.3775
Template load and register function0.00030.034510.0003
states
state_id_array0.00130.162010.0013
state_identifier_array0.00160.208520.0008
Override
Cache load0.00150.1925170.0001
Sytem overhead
Fetch class attribute can translate value0.00040.055410.0004
Fetch class attribute name0.00060.079010.0006
XML
Image XML parsing0.00010.015410.0001
class_abstraction
Instantiating content class attribute0.00000.000510.0000
General
dbfile0.00300.3846100.0003
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 4
 Number of unique templates used: 4

Time used to render debug report: 0.0001 secs