Working With Favorites

The rest_v2/favorites service provides methods that allow you to add the resources to Favorites for quick access, remove the resources from Favorites and see the starred resources in your list of Favorites.

This chapter includes the following sections:

Adding Resources to Favorites
Removing Resources from Favorites
Accessing Resources in Favorites

Adding Resources to Favorites

Use the following method to add the resources to Favorites.

Method

URL

POST

http://<host>:<port>/jasperserver[-pro]/rest_v2/favorites

Content-Type

Content

application/json

A JSON object that contains the list of resource URIs to be added to Favorites.

Return Value on Success

Typical Return Values on Failure

201 Created – The request was successful.

400 Bad Request – Invalid request syntax.
403 Forbidden – When the logged-in user does not have permission to access the resource.
404 Not Found – When the resource specified in the request does not exist.

The following is an example of sample payload.

Sample Request Payload:

{
    "favorites":[
     {
        "uri":"/public/audit/datasources/AuditDataSource_1"
     },
     {
        "uri":"/public/audit/datasources/AuditVirtualDataSource_1"
     }
   ]
}

Sample Response Payload:

{
    "favorites":[
     {
        "uri":"/public/audit/datasources/AuditDataSource_1"
     },
     {
        "uri":"/public/audit/datasources/AuditVirtualDataSource_1"
     }
   ]
}

If a user adds a resource to the Favorites and later an admin removes user's access to resources, the entry stays in the jifavoriteresource table, but user will not be able to view or remove the resources from the Favorites.

Local resources cannot be added to Favorites.

Removing Resources from Favorites

The following method is used to remove the starred resources from the Favorites.

Method

URL

POST

http://<host>:<port>/jasperserver[-pro]/rest_v2/favorites/delete

Content-Type

Content

application/json

A JSON object that contains the list of resource URIs to be deleted from Favorites.

Return Value on Success

Typical Return Values on Failure

204 No Content – The request was successful.

400 Bad Request – Invalid request syntax.
403 Forbidden – When the logged-in user does not have permission to access the resource.
404 Not Found – When the resource specified in the request does not exist.

Accessing Resources in Favorites

Use the following method to get the list of favorites. By default, favorites is false. For more information, see Searching the Repository.

Method

URL

GET

http://<host>:<port>/jasperserver[-pro]/rest_v2/resources?favorites=true

Content-Type

Content

application/json

A JSON object that lists the resources added to Favorites.

Return Value on Success

Typical Return Values on Failure

200 OK – The body contains a list of Favorites representing the results of the search.

404 Not Found – When the resource specified in the request does not exist.
204 No content – When the resources added to Favorites are not found.