Last active
July 17, 2017 15:25
-
-
Save arfaram/d2914bf089f6fa4db1eb23cf23fe1844 to your computer and use it in GitHub Desktop.
RichText_REST_API_ezpublish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -i -X POST http://site.ezplatform.com/api/ezp/v2/content/objects --data @content.xml -H 'Content-Type:application/vnd.ez.api.ContentCreate+xml' -H 'Accept:application/xml' --user admin:publish | |
#REST API Tested with ezplatform 1.5 (using RichTextField ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<ContentCreate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | |
<ContentType href="/api/ezp/v2/content/types/14"/> | |
<mainLanguageCode>eng-GB</mainLanguageCode> | |
<LocationCreate> | |
<ParentLocation href="/api/ezp/v2/content/locations/1/2/58/59/61" /> | |
<priority>0</priority> | |
<hidden>false</hidden> | |
<sortField>PATH</sortField> | |
<sortOrder>ASC</sortOrder> | |
</LocationCreate> | |
<Section href="/api/ezp/v2/content/sections/1"/> | |
<alwaysAvailable>true</alwaysAvailable> | |
<remoteId></remoteId> | |
<fields> | |
<field> | |
<fieldDefinitionIdentifier>name</fieldDefinitionIdentifier> | |
<languageCode>eng-GB</languageCode> | |
<fieldValue>This is a title6</fieldValue> | |
</field> | |
<field> | |
<fieldDefinitionIdentifier>body</fieldDefinitionIdentifier> | |
<languageCode>eng-GB</languageCode> | |
<fieldValue> | |
<value key="xml"><![CDATA[<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit"><h1>gtz</h1><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet</p></section>]]></value> | |
</fieldValue> | |
</field> | |
</fields> | |
</ContentCreate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested with ezplatform 1.5.1 | |
See Fix: https://github.com/ezsystems/ezpublish-kernel/commit/1163b53059329cd9a22ae3a2d92d709a1f48fc88 ( eZ version < 1.5.1) | |
eZPublish5 REST API Doc: https://github.com/ezsystems/ezpublish-kernel/blob/master/doc/specifications/rest/REST-API-V2.rst#contentupdate-xml-schema | |
Basic authentication in security.yml: | |
ezpublish_rest: | |
pattern: ^/api/ezp/v2 | |
stateless: true | |
ezpublish_http_basic: | |
realm: eZ Publish REST API | |
Note: this example will just create a draft ! | |
To publish the draft USE: | |
POST | |
http://site.ezplatform.com/api/ezp/v2/content/objects/108/versions/1 | |
with Header: | |
- Basic Auth | |
- X-HTTP-Method-Override:Publish | |
CURL publish example: | |
curl -i -X POST http://site.ezplatform.com/api/ezp/v2/content/objects/106/versions/1 -H 'X-HTTP-Method-Override:Publish' --user admin:publish | |
PS: 106 is the ObjectId returning by the first draft Response. | |
Response Example: | |
HTTP/1.1 204 No Content <--- everything is OK | |
Date: Sun, 23 Oct 2016 19:52:38 GMT | |
Server: Apache/2.4.7 (Ubuntu) | |
Cache-Control: no-cache | |
X-Cache-Debug: 1 | |
Vary: Cookie,Authorization | |
X-Debug-Token: 76a43b | |
X-Debug-Token-Link: http://site.ezplatform.com/_profiler/76a43b | |
Content-Length: 0 | |
Connection: close | |
Content-Type: text/html; charset=UTF-8 | |
More Info on ezpublish5, ezplatform REST API publish content: | |
https://github.com/ezsystems/ezpublish-kernel/blob/master/doc/specifications/rest/REST-API-V2.rst#publish-a-content-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Status Code: 201 Created | |
Accept-Patch: application/vnd.ez.api.ContentUpdate+xml | |
Cache-Control: no-cache | |
Connection: close | |
Content-Length: 1131 | |
Content-Type: application/vnd.ez.api.ContentInfo+xml | |
Date: Sun, 23 Oct 2016 16:23:22 GMT | |
Location: /api/ezp/v2/content/objects/104 | |
Server: Apache/2.4.7 (Ubuntu) | |
Vary: Cookie,Authorization | |
X-Cache-Debug: 1 | |
X-Debug-Token: d02431 | |
X-Debug-Token-Link: http://site-ezplatform.com/_profiler/d02431 |
Thanks for your update. Now getting validation error "Argument '$inputValue' is invalid: Could not create XML document: Extra content at the end of the document"
I added the XML Tag at the file beginn and checked your gist also hier: https://gist.github.com/bdunogier/3918294
everything looks good !
I think from 1.5.0 to 1.5.1 this is not the only Fix (ezsystems/ezpublish-kernel@1163b53). something still missed
Okay get it works today
- < paragraph > Tag not allowed
- Content must be within < p > or valid HTML Tag < h1 > etc
- Line break will not works between < value key="xml" > and < ![CDATA ..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The input for RichText should look like this (don't forget to wrap it into
<![CDATA[...]]>
in XML):