+

Search Tips   |   Advanced Search

Use REST with content items

Use the WCM REST service to create, read, update, and delete content items.


Create

A content item can be created by sending a POST request to the following URI with an atom entry representing the content item:

    /Content

  • A library or parent link relation must be specified. This tells the REST service the location of the hierarchical item being created.

  • An authoring template must be specified. This tells the REST service what authoring template to use when creating the item.

  • zse43ed

For example:

    POST

    HTTP/1.1 POST http://host:port/wps/mycontenthandler/wcmrest/Content/ Content-Type: application/atom+xml <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace"> <wcm:name>Content Name</wcm:name> <atom:title>Content Title</atom:title> <atom:link atom:rel="parent" atom:href="/wps/mycontenthandler/wcmrest/item/49f4ed95-a99f-434c-a415-77c341fa4893"/> <atom:link atom:rel="workflow" atom:href="/wps/mycontenthandler/wcmrest/item/abae799b-4cca-47ae-aad8-b3d8204deefb"/> <atom:link atom:rel="content-template" atom:href="/wps/mycontenthandler/wcmrest/item/588127d0-a4f8-44b5-87a4-5fe3f7bd3da7"/> </atom:entry>

    Response:

      201 Created


Create from a skeleton

A "skeleton" representation of a content item created from a content template can be obtained to aid in the creation of content items. This can be obtained by issuing a GET request to the following URI. Once the skeleton is obtained and completed a POST request can be made using this data to create the item.

    /ContentTemplate/template-uuid/new-content

For example:

HTTP/1.1 GET http://host:port/wps/mycontenthandler/wcmrest/ContentTemplate/b7b8b3fb-8fa1-4eb3-915e-ce7514f7067f/new-content
 Response  200 OK
 <?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/wcm">
    <id>wcmrest:6bab48c6-1f24-454e-9bab-ae1be4cf3a0a</id>
    <title lang="en"></title>
    <summary lang="en"></summary>
    <wcm:name></wcm:name>
    <wcm:type>Content</wcm:type>
    <updated>2012-01-31T03:28:08.118Z</updated>
    <author>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!7K1PhYjxBw0jzCDqHCwg2w/um/users/profiles/Z9eAeHPCAJG963RD2MMG6P9O6MMG66BD6MM47IHP4MMS6M1DAJQ4C1BCAMID653</uri>
        <name>wpsadmin</name>
    </author>
    <wcm:owner>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!7K1PhYjxBw0jzCDqHCwg2w/um/users/profiles/Z9eAeHPCAJG963RD2MMG6P9O6MMG66BD6MM47IHP4MMS6M1DAJQ4C1BCAMID653</uri>
        <name>wpsadmin</name>
    </wcm:owner>
    <link label="Library" rel="library" href="/wps/mycontenthandler/!ut/p/digest!PQo5Yhy68oeppWcEz2sddA/wcmrest/item/a423287f-b0ce-4ee3-9c95-aa0939382228" lang="en"/>
    <link label="Content Template" rel="content-template" href="/wps/mycontenthandler/!ut/p/digest!PQo5Yhy68oeppWcEz2sddA/wcmrest/Content/b7b8b3fb-8fa1-4eb3-915e-ce7514f7067f" lang="en"/>
    <content type="application/vnd.ibm.wcm+xml">
        <content xmlns="http://www.ibm.com/xmlns/wcm">
            <elements>
  <element name="Body">
      <title lang="en">Body</title>
      <type>RichTextComponent</type>
      <data type="text/html"></data>
  </element>
            </elements>
        </content>
    </content>
</entry>


Update

A content item can be updated by sending a PUT request to the following URI with an atom entry including the fields on the item that need to be changed.

    /Content/item-uuid

For example:

    PUT

    HTTP/1.1 PUT http://host:port/wps/mycontenthandler/wcmrest/Content/abae799b-4cca-47ae-aad8-b3d8204deefb Content-Type: application/atom+xml <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace"> <wcm:name>Updated Content Name</wcm:name> <atom:title>Updated Content Title</atom:title> </atom:entry>

    Response:

      200 OK


Read

A content item can be read by sending a GET request to the following URI :

    /Content/item-uuid

For example:

    GET

    HTTP/1.1 GET http://host:port/wps/mycontenthandler/wcmrest/Content/fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa <atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace"> <atom:id>fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa</atom:id> <wcm:name>content name145805586</wcm:name> <atom:title>content title145805586</atom:title> <wcm:type>Content</wcm:type> <atom:updated>2011-04-27T04:06:32.643Z</atom:updated> <atom:link atom:rel="edit" atom:href="/wps/mycontenthandler/wcmrest/Content/fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa"/> <atom:link atom:rel="library" atom:href="/wps/mycontenthandler/wcmrest/item/957a67f2-9d70-469f-9d43-f63f78508e48"/> <atom:link atom:rel="parent" atom:href="/wps/mycontenthandler/wcmrest/item/49f4ed95-a99f-434c-a415-77c341fa4893"/> <atom:link atom:rel="workflow-stage" atom:href="/wps/mycontenthandler/wcmrest/item/f659d3af-7d45-4fc0-ad37-86e407caf2b6"/> <atom:link atom:rel="workflow" atom:href="/wps/mycontenthandler/wcmrest/item/abae799b-4cca-47ae-aad8-b3d8204deefb"/> <atom:link atom:rel="versions" atom:href="/wps/mycontenthandler/wcmrest/item/fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa/versions"/> <atom:link atom:rel="content-template" atom:href="/wps/mycontenthandler/wcmrest/item/588127d0-a4f8-44b5-87a4-5fe3f7bd3da7"/> <atom:link atom:rel="elements" atom:href="/wps/mycontenthandler/wcmrest/Content/fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa/elements"/> </atom:entry>

    Response:
    200 OK


Delete

A content item can be deleted by sending a DELETE request to the following URI:

    /Content/item-uuid

For example:

    DELETE

    HTTP/1.1 DELETE http://host:port/wps/mycontenthandler/wcmrest/Content/fa2bfd32-7b2f-4394-a5ab-2e150c5ed8aa/

    Response:

      200 OK


Parent Work with web content items using REST