Developers

GetContents

Usage

Use this method to retrieve all content from the Knowledge Base:

client.getContents(options:Object).then(function(response){
    //...
});

Mandatory parameters

This method does not have any mandatory parameters.

Options

Name Type Default Description
categoryId string 0 Category identifier from the Knowledge Base. Category id 0 is reserved for the root. This parameter allows a string with the categories separated by commas. Example: 1,4,5 will search in the categories 1, 4 and 5.
length integer 5 Maximum number of items that may be returned in a collection. Minimum:1. Max:100
offset integer 0 Starting index within the collection of resource result. Minimum:0.
sortBy string Not sorted by default Sort the contents by specific attribute. Valid values: ‘creationDate’ and ‘modificationDate’.

Response data format

This method calls the Knowledge API’s GET /contents endpoint. Please refer to the Responses section of that endpoint on the Knowledge API Routes page for the response format.

Example

The following example is set to get a maximum of 20 contents from category "1,4,5" sorted by modification date:

client.getContents({
    categoryId: '1,4,5'
    length: 20,
    offset: 0,
    sortBy: 'modificationDate'
}).then(function(response){
    response.data.results.forEach(function(result) {
        console.log(`Result(${result.id}): ${result.title}`);
    });
});