How to use REST with libraries | HCL Digital Experience

You can use the Web Content Manager REST service to create, read, update, and delete libraries.

Create

A library can be created by sending a POST request to the following URI:
/Library
For example:
HTTP/1.1 POST /wps/mycontenthandler/wcmrest/Library
Content-Type: application/atom+xml

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/wcm/8.0">
    <wcm:name>My Library</wcm:name>
    <content type="application/vnd.ibm.wcm+xml">
        <wcm:library xmlns="http://www.ibm.com/xmlns/wcm/8.0">
            <allowDeletion>false</allowDeletion>
            <enabled>true</enabled>
            <language>en</language>
            <includeDefaultItems>true</includeDefaultItems>
        </wcm:library>
    </content>
</entry>

HTTP 201 Created

Update

An existing library can be updated by sending a PUT request to the following URI:
/Library/library-id
For example:
HTTP/1.1 PUT /wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c
Content-Type: application/atom+xml
Accept: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/wcm/8.0">
    <id>wcmrest:ff207ba6-ac9a-4b38-b831-99528ff5067c</id>
    <title>My New Library Title</title>
    <summary/>
    <wcm:name>my library</wcm:name>
    <wcm:type>Library</wcm:type>
    <updated>2014-10-09T03:18:02.303Z</updated>
    <link rel="self" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Read"/>
    <link rel="edit" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Edit"/>
    <link rel="delete" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Delete"/>
    <link rel="access-control" href="/wps/mycontenthandler/ac/access:oid:Z6QReDe6JP43OS62BOCJM4C3BE2MMG62RCGJM8COPC2JM47P9D43SOC6BD03RS633" xml:lang="en" label="Access Control"/>
    <link rel="edit-media" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" type="application/vnd.ibm.wcm+xml" xml:lang="en" label="Edit Media"/>
    <link rel="preset-folders" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c/preset-folders"/>
    <content type="application/vnd.ibm.wcm+xml">
        <wcm:library xmlns="http://www.ibm.com/xmlns/wcm/8.0">
            <allowDeletion>true</allowDeletion>
            <enabled>true</enabled>
            <language>en</language>
        </wcm:library>
    </content>
</entry>

HTTP 200 OK

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/wcm/8.0">
    <id>wcmrest:ff207ba6-ac9a-4b38-b831-99528ff5067c</id>
    <title>My New Library Title</title>
    <summary/>
    <wcm:name>my library</wcm:name>
    <wcm:type>Library</wcm:type>
    <updated>2014-10-09T03:18:02.303Z</updated>
    <link rel="self" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Read"/>
    <link rel="edit" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Edit"/>
    <link rel="delete" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Delete"/>
    <link rel="access-control" href="/wps/mycontenthandler/ac/access:oid:Z6QReDe6JP43OS62BOCJM4C3BE2MMG62RCGJM8COPC2JM47P9D43SOC6BD03RS633" xml:lang="en" label="Access Control"/>
    <link rel="edit-media" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" type="application/vnd.ibm.wcm+xml" xml:lang="en" label="Edit Media"/>
    <link rel="preset-folders" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c/preset-folders"/>
    <content type="application/vnd.ibm.wcm+xml">
        <wcm:library xmlns="http://www.ibm.com/xmlns/wcm/8.0">
            <allowDeletion>true</allowDeletion>
            <enabled>true</enabled>
            <language>en</language>
        </wcm:library>
    </content>
</entry>

Read

An existing library can be read by sending a GET request to the following URI:
/Library/library-id
For example:
HTTP/1.1 GET /wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c
Accept: application/atom+xml

HTTP 200 OK

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/wcm/8.0">
    <id>wcmrest:ff207ba6-ac9a-4b38-b831-99528ff5067c</id>
    <title>My Library</title>
    <summary/>
    <wcm:name>my library</wcm:name>
    <wcm:type>Library</wcm:type>
    <updated>2014-10-09T03:18:02.303Z</updated>
    <link rel="self" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Read"/>
    <link rel="edit" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Edit"/>
    <link rel="delete" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" xml:lang="en" label="Delete"/>
    <link rel="access-control" href="/wps/mycontenthandler/ac/access:oid:Z6QReDe6JP43OS62BOCJM4C3BE2MMG62RCGJM8COPC2JM47P9D43SOC6BD03RS633" xml:lang="en" label="Access Control"/>
    <link rel="edit-media" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c" type="application/vnd.ibm.wcm+xml" xml:lang="en" label="Edit Media"/>
    <link rel="preset-folders" href="/wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c/preset-folders"/>
    <content type="application/vnd.ibm.wcm+xml">
        <wcm:library xmlns="http://www.ibm.com/xmlns/wcm/8.0">
            <allowDeletion>false</allowDeletion>
            <enabled>true</enabled>
            <language>en</language>
        </wcm:library>
    </content>
</entry>

Delete

An existing library can be deleted by sending a DELETE request to the following URI:
/Library/library-id
For example:
HTTP/1.1 DELETE /wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c

HTTP 200 OK

Asynchronous Delete

An existing library can also be deleted asynchronously by using the following URI. The response contains a 'Content-Location' header, containing a URI that can be used to monitor the progress of the delete operation:
/Library/library-id?synchronous=true
For example:
HTTP/1.1 DELETE /wps/mycontenthandler/wcmrest/Library/ff207ba6-ac9a-4b38-b831-99528ff5067c?synchronous=true

HTTP 202 Accepted
Content-Location: /wps/mycontenthandler/wcmrest/Library/fd18e3a0-b96b-4a66-9bcc-f3d142c7837e/wcmTask:com.ibm.workplace.wcm.services.task.DeleteTask:ced02fae-abc7-4ff4-af4d-c08804b32811/delete-status