How to use REST with drafts and workflows | HCL Digital Experience
You can use the REST services for HCL Web Content Manager to create drafts, approve items
in a workflow, retrieve workflow comments from content items, and move items through
different stages of a workflow.
New with HCL Digital Experience 9.5 Container Update 18_1 and higher releases,
two new APIs are added to handle Process Now and Remove Workflow from an item
functionality. HCL DX 9.5 CF19 and higher release adds support to retrieve workflow
comments from content items.
Creating a draft of an item that does not use a workflow
You
can create a draft of items that do not use workflows.
To do
that, specify explicitly the draft workflow state in the request entry
data. For example, to create a link component as draft:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/LibraryLinkComponent
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
<wcm:name>linkDraft_E</wcm:name>
<atom:link atom:rel="library" atom:href="/wps/mycontenthandler/!ut/p/wcmrest/item/d07f0a12-3801-465e-bc20-eaec2cecf5cb"/>
<category label="Draft" scheme="wcmrest:workflowState" term="DRAFT"/>
</atom:entry>
201 Created
Creating a draft in a workflow
You can use the REST service to create a new draft item. This is equivalent to using the
Create Draft icon in the authoring portlet.
A new draft of an item can be created by sending a
POST request to the following URI:
/item/item-uuid/create-draft
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/item-uuid/create-draft
201 Created
Moving an item to the next stage
You can use the REST service to move an item to the next stage of a workflow. This is equivalent
to using the Next Stage icon in the authoring portlet.
An item can be moved to the next stage
by sending a POST request to the following URI:
/item/item-uuid/next-stage
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/<item-uuid>/next-stage
201 Created
Moving an item to the previous stage
You can use the REST service to move an item to the previous stage of a workflow. This is
equivalent to using the Previous Stage icon in the authoring portlet.
An item can be moved to the previous
stage by sending a POST request to the following URI:
/item/item-uuid/previous-stage
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/item-uuid/previous-stage
201 Created
Approving an item within a workflow
You can use the REST service to move an item to the next stage of a workflow by approving it.
This is equivalent to using the Approve icon in the authoring portlet.
An item can be approved by sending
a POST request to the following URI:
/item/item-uuid/approve
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/item-uuid/approve
201 Created
Rejecting an item within a workflow
You can use the REST service to reject an item in a workflow. This is equivalent to using the
Reject icon in the authoring portlet.
An item can be rejected by sending a POST
request to the following URI:
/item/item-uuid/reject
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/item-uuid/reject
201 Created
Restarting a workflow
You can use the REST service to restart a workflow. This is equivalent to using the
Restart icon in the authoring portlet.
An item can be restarted by sending
a POST request to the following URI:
/item/item-uuid/restart
For
example:
HTTP/1.1 POST
http://host:port/wps/mycontenthandler/wcmrest/item/item-uuid/restart
201 Created
Workflow Comments
To ensure that comments
are added to workflow stages that require comments, a GET request
must be issued to the associated link. This will return an HTML form indicating
whether a comment is required.
To add the comment you either submit the form, or perform an HTTP Post request with a content
type of text/plain.
The Process Now and Remove Workflow from an item functionality are equivalent to their
functionality in user interfaces:Figure 1. Process NowFigure 2. Remove Workflow
Using the Process Now API
Endpoint
POST request to:
http://host:port/wps/mycontenthandler/wcmrest/item/<(UUID of the
content)>/process-now