Skip to content

Instantly share code, notes, and snippets.

@emodric
Created May 3, 2013 10:51
Show Gist options
  • Save emodric/5508478 to your computer and use it in GitHub Desktop.
Save emodric/5508478 to your computer and use it in GitHub Desktop.
Updating eztags field and publishing content over eZ Publish 5 REST API
eddie@abyss: ~/restScripts/xml/content [master] $ ./05-updateVersion.sh
POST /api/ezp/v2/content/objects/62/versions/2 HTTP/1.1
Accept: application/vnd.ez.api.Version+xml
Accept-Encoding: gzip, deflate, compress
Content-Length: 1192
Content-Type: application/vnd.ez.api.VersionUpdate+xml
Host: ezpublish5.local
User-Agent: HTTPie/0.4.1
X-HTTP-Method-Override: PATCH
<?xml version="1.0" encoding="UTF-8"?>
<VersionUpdate>
<initialLanguageCode>eng-GB</initialLanguageCode>
<fields>
<field>
<id>622</id>
<fieldDefinitionIdentifier>eztags</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value>
<value key="id">1</value>
<value key="parent_id">0</value>
<value key="main_tag_id">0</value>
<value key="keyword">Test tag 1</value>
<value key="depth">1</value>
<value key="path_string">/1/</value>
<value key="modified">1367577014</value>
<value key="remote_id">b397e666887ab85c1d406598fdbd7458</value>
</value>
<value>
<value key="id">2</value>
<value key="parent_id">0</value>
<value key="main_tag_id">0</value>
<value key="keyword">Test tag 2</value>
<value key="depth">1</value>
<value key="path_string">/2/</value>
<value key="modified">1367577189</value>
<value key="remote_id">97034c28a78e214d0878f5ed4d1b6f39</value>
</value>
</fieldValue>
</field>
</fields>
</VersionUpdate>
HTTP/1.1 200 OK
Accept-Patch: application/vnd.ez.api.VersionUpdate+xml
Cache-Control: no-cache
Content-Type: application/vnd.ez.api.Version+xml
Date: Fri, 03 May 2013 10:48:25 GMT
Server: Apache/2.2.22 (Ubuntu)
Transfer-Encoding: chunked
X-Powered-By: PHP/5.4.14-1~ppa1~quantal
<?xml version="1.0" encoding="UTF-8"?>
<Version media-type="application/vnd.ez.api.Version+xml" href="/api/ezp/v2/content/objects/62/versions/2">
<VersionInfo>
<id>559</id>
<versionNo>2</versionNo>
<status>DRAFT</status>
<modificationDate>2013-05-03T12:48:25+02:00</modificationDate>
<Creator media-type="application/vnd.ez.api.User+xml" href="/api/ezp/v2/user/users/14"/>
<creationDate>2013-05-03T12:39:24+02:00</creationDate>
<initialLanguageCode>eng-GB</initialLanguageCode>
<languageCodes>eng-GB</languageCodes>
<names>
<value languageCode="eng-GB">eZ Publish Tutorials</value>
</names>
<Content media-type="application/vnd.ez.api.ContentInfo+xml" href="/api/ezp/v2/content/objects/62"/>
</VersionInfo>
<Fields>
<field>
<id>216</id>
<fieldDefinitionIdentifier>title</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>eZ Publish Tutorials</fieldValue>
</field>
<field>
<id>217</id>
<fieldDefinitionIdentifier>short_title</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue/>
</field>
<field>
<id>219</id>
<fieldDefinitionIdentifier>intro</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value key="xml">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;section xmlns:image=&quot;http://ez.no/namespaces/ezpublish3/image/&quot; xmlns:xhtml=&quot;http://ez.no/namespaces/ezpublish3/xhtml/&quot; xmlns:custom=&quot;http://ez.no/namespaces/ezpublish3/custom/&quot;&gt;&lt;paragraph xmlns:tmp=&quot;http://ez.no/namespaces/ezpublish3/temporary/&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;paragraph xmlns:tmp=&quot;http://ez.no/namespaces/ezpublish3/temporary/&quot;&gt;&lt;link url_id=&quot;29&quot; url=&quot;http://doc.ez.no/Tutorials/Developing-eZ-Publish-extensions&quot;&gt;Developing eZ Publish Extensions&lt;/link&gt;&lt;/paragraph&gt;&lt;/li&gt;&lt;li&gt;&lt;paragraph xmlns:tmp=&quot;http://ez.no/namespaces/ezpublish3/temporary/&quot;&gt;&lt;link url_id=&quot;30&quot; url=&quot;http://doc.ez.no/Tutorials/Building-mobile-browser-and-hybrid-applications-with-eZ-Publish&quot;&gt;Building mobile browser and hybrid applications with eZ Publish&lt;/link&gt;&lt;/paragraph&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/paragraph&gt;&lt;/section&gt;
</value>
</fieldValue>
</field>
<field>
<id>220</id>
<fieldDefinitionIdentifier>body</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value key="xml">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;section xmlns:image=&quot;http://ez.no/namespaces/ezpublish3/image/&quot; xmlns:xhtml=&quot;http://ez.no/namespaces/ezpublish3/xhtml/&quot; xmlns:custom=&quot;http://ez.no/namespaces/ezpublish3/custom/&quot;/&gt;
</value>
</fieldValue>
</field>
<field>
<id>222</id>
<fieldDefinitionIdentifier>caption</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value key="xml">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;section xmlns:image=&quot;http://ez.no/namespaces/ezpublish3/image/&quot; xmlns:xhtml=&quot;http://ez.no/namespaces/ezpublish3/xhtml/&quot; xmlns:custom=&quot;http://ez.no/namespaces/ezpublish3/custom/&quot;/&gt;
</value>
</fieldValue>
</field>
<field>
<id>223</id>
<fieldDefinitionIdentifier>publish_date</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value key="timestamp">0</value>
<value key="rfc850">Thursday, 01-Jan-70 00:00:00 GMT+0000</value>
</fieldValue>
</field>
<field>
<id>622</id>
<fieldDefinitionIdentifier>eztags</fieldDefinitionIdentifier>
<languageCode>eng-GB</languageCode>
<fieldValue>
<value>
<value key="id">1</value>
<value key="parent_id">0</value>
<value key="main_tag_id">0</value>
<value key="keyword">Test tag 1</value>
<value key="depth">1</value>
<value key="path_string">/1/</value>
<value key="modified">1367577014</value>
<value key="remote_id">b397e666887ab85c1d406598fdbd7458</value>
</value>
<value>
<value key="id">2</value>
<value key="parent_id">0</value>
<value key="main_tag_id">0</value>
<value key="keyword">Test tag 2</value>
<value key="depth">1</value>
<value key="path_string">/2/</value>
<value key="modified">1367577189</value>
<value key="remote_id">97034c28a78e214d0878f5ed4d1b6f39</value>
</value>
</fieldValue>
</field>
</Fields>
<Relations media-type="application/vnd.ez.api.RelationList+xml" href="/api/ezp/v2/content/objects/62/versions/2/relations"/>
</Version>
eddie@abyss: ~/restScripts/xml/content [master] $ ./12-publishContentVersion.sh
PUBLISH /api/ezp/v2/content/objects/62/versions/2 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate, compress
Content-Length: 0
Host: ezpublish5.local
User-Agent: HTTPie/0.4.1
X-HTTP-Method-Override: PUBLISH
HTTP/1.1 204 No Content
Cache-Control: no-cache
Content-Type: text/html; charset=UTF-8
Date: Fri, 03 May 2013 10:50:15 GMT
Server: Apache/2.2.22 (Ubuntu)
Status: 204 No Content
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.14-1~ppa1~quantal
eddie@abyss: ~/restScripts/xml/content [master] $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment