Finding all the Content Sets in the Server

Problem

You want to obtain a list of all the previously created Content Sets contained in the PReS Connect Server potentially for use in a Job Creation operation.

Solution

The solution is to create a request using the following URI and method type and submit it to the server via the Content Set Entity REST service:

Get All Content Sets /rest/serverengine/entity/contentsets GET

Example

HTML5

cse-get-all-contentsets.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Get All Content Sets Example</title>
        <script src="../../common/lib/js/jquery-3.4.1.min.js"></script>
        <script src="../../common/js/common.js"></script>
        <script src="js/cse-get-all-contentsets.js"></script>
        <link rel="stylesheet" href="../../common/css/styles.css">
    </head>
    <body>
        <h2>Content Set Entity Service - Get All Content Sets Example</h2>
        <form>
            <fieldset>
                <legend>Options</legend>
                <div>
                    <label for="type">Entity Type:</label>
                    <select id="type">
                        <option value="default">Default</option>
                        <option value="print">Print</option>
                        <option value="email">Email</option>
                    </select>
                </div>
            </fieldset>
            <fieldset>
                <legend>Actions</legend>
                <div>
                    <input id="submit" type="submit" value="Submit">
                </div>
            </fieldset>
        </form>
    </body>
</html>

JavaScript/jQuery

cse-get-all-contentsets.js

/* Content Set Entity Service - Get All Content Sets Example */
(function ($, c) {
    "use strict";
    $(function () {

        c.setupExample();

        $("form").on("submit", function (event) {

            event.preventDefault();
            if (!c.checkSessionValid()) return;

            var type = $("#type").val();

            var settings = {
                type: "GET",
                url:  "/rest/serverengine/entity/contentsets"
            };
            if (type !== "default") settings.data = { type: type };
            $.ajax(settings)
                .done(function (response) {
                    c.displayStatus("Request Successful");
                    c.displayHeading("Content Set IDs");
                    c.displaySubResult("Plain", c.jsonIDListToPlain(response));
                    c.displaySubResult("JSON Identifier List", c.jsonPrettyPrint(response));
                })
                .fail(c.displayDefaultFailure);
        });
    });
}(jQuery, Common));

Screenshot & Output

Usage

To run the example simply select the Submit button to request a list of the all the content sets currently contained within the server.

The resulting list will then be returned and displayed to the Results area in both Plain list and JSON Identifier List formats.

Further Reading

See the Content Set Entity Service page of the REST API Reference section for further detail.