+

Search Tips   |   Advanced Search

Use REST to work with favorite items

We can use REST service to display a list of favorite items. This is the equivalent of the Favorite Items view in the library explorer.


Parameters

The following parameters, along with mime-type, are the only parameters that will work with the returned feed. All other parameters will be ignored.

Parameter Details
sort The sort parameter is appended to queries to determine how query results are sorted. The following values can be used with the sort parameter.

  • author

  • created

  • modified

  • name

  • title

The values _ascending or _descending are appended to the query to determine sort order.

For example, to sort a presentation template query in ascending order of creation, you would use:

/favorite-items?type=PresentationTemplate&sort=created_ascending

To sort a presentation template query in descending order of creation, you would use:

/favorite-items?type=PresentationTemplate&sort=created_descending
If _ascending or _descending are not specified, the results as displayed in ascending order.
type This parameter is used to query items of a specific item type.

For example, to query a list of components::

/favorite-items?type=LibraryHTMLComponent
page This parameter is used with the pagesize parameter to define what set of results to display. For example, if pagesize is set to 5, and the page parameter is set to 2, then only results 6 to 10 will be displayed.

For example:

/favorite-items?type=PresentationTemplate&pagesize=5&page=2
pagesize This parameter is used to restrict the number of items returned by a query to a set number. It can be used with the page parameter to return specific pages of results.

For example, to restrict the number of queries to be returned to 5:

/favorite-items?type=PresentationTemplate&pagesize=5


Add and removing favorite items

For item types that have an explicit REST URI, such as types that can be created or updated, the item can be added by performing a HTTP PUT to update the item, with the PUT request containing the favorites category.

For example:

HTTP 1.1 PUT /wps/mycontenthandler/wcmrest/LibraryHTMLComponent/47018149-fc6b-46af-a54d-1eab89a6fed7
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="http://www.ibm.com/xmlns/8.0">
  ... data ...
    <category scheme="wcmrest:favorite" term="true" lang="en"/>
    ... data ...
</entry>

For items that do not have an explicit REST URI, a HTTP POST request can be made specifying the generic URI of the item. For this to work the item must be created already.

For example:

The item-uri parameter specifies the item to add, and may be in the expanded form, as shown in the previous examples, or the compact form. For example:

wcmrest:item/65a46943-ed1c-4f5d-b497-03c18886ca8e


Parent: Work with web content items using REST