Bridgeline Digital Logo
Menu

Taxonomy API

The OrchestraCMS Taxonomy API provides programmatic access to the taxonomy structures in your site and their interaction with other content items. 

TaxonomyAPIRequest

A Taxonomy API request is made up of  the following properties. Requirements may differ depending on the API method used:

  • bundle: TaxonomyBundle, The taxonomy bundle to use in a given API method.
  • contentId: String, The content ID to retrieve, add or set or remove tags from.
  • childrenToAdd:  List<TaxonomyBundle>, The list of TaxonomyBundles to add as child nodes to an unpublished taxonomy.
  • categories: List<TaxonomyBundle>, The list of TaxonomyBundles to set, add or remove tags from a piece of content.

taxonomyRequest.requestFlags (Map<String, Boolean>)

  • latest: (optional, default: true), The state of the content that should be retrieved. This will return unpublished versions when sent to false.
  • fullTree: (optional, default: false), Retrieves the full tree of child nodes. Only the list of immediate children of given bundles tagId are returned when set to false. 

taxonomyRequest.parameters (Map<String, String>)

  • taxonomy, The ID of the taxonomy that the tags being added to the content come from.

addChildrenToNode

This method adds child nodes to a taxonomy node.

Parameters

  • bundle: TaxonomyBundle, The taxonomy bundle that will have child nodes added to it.
  • bundle.children: List<TaxonomyBundle>, The list of new TaxonomyBundles to create child nodes from.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();

TaxonomyBundle childBundle = new TaxonomyBundle(); // Create a new taxonomy bundle as a child node
childBundle.taxonomyID = 'a00000000000000000'; // Replace with your taxonomy Id
childBundle.depth = 1;
childBundle.languageMapOfTagNames = new Map<String, String>{'en_US' => 'Level 1-1c'};

taxonomyRequest.bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
taxonomyRequest.bundle.taxonomyID = 'a00000000000000000';
taxonomyRequest.bundle.tagDefinitionID = 'a01000000000000000';
taxonomyRequest.bundle.depth = 0;
taxonomyRequest.bundle.children = new List<TaxonomyBundle>{childBundle};
taxonomyRequest.childrenToAdd = new List<TaxonomyBundle>{childBundle};

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'addChildrenToNode');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to add children to node.');
}
if (apiResponse.type != 'TaxonomyBundle') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Successfully renamed the node.' on success

JavaScript Request

var bundleChildren = [
    {
        taxonomyID: 'a00000000000000000',
        depth: 1,
        languageMapOfTagNames: {
            en_US: 'Level 1-1c'
        }
    }
];
var apiRequest = {
    bundle: { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
        taxonomyID: 'a00000000000000000',
        tagDefinitionID: 'a01000000000000000',
        depth: 0,
        children: bundleChildren
    },
    childrenToAdd: bundleChildren,
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'addChildrenToNode',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // addChildrenToNode Request
 
A TaxonomyBundle is passed in as the parent and a list of bundles is passed in as the children to be created.
 
You must have a lock on an unpublished taxonomy to add child nodes to it.

addTagToContent

This method adds the tagPath to the specified content ID.

Parameters

  • parameters: Map<String, String>, The parameters map must contain a key of taxonomy  with a value of a Taxonomy ID.
  • contentId: String, The content ID where the tag should be added.
  • bundle: TaxonomyBundle, The TaxonomyBundle that will be added to the content.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.parameters = new Map<String, String>{'taxonomy' => 'a00000000000000001'};
taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

taxonomyRequest.bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
taxonomyRequest.bundle.taxonomyID = 'a00000000000000001';
taxonomyRequest.bundle.tagDefinitionID = 'a01000000000000000';

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'addTagToContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to add the tag to this content.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Tag was added to the content successfully.' on success

JavaScript Request

var apiRequest = {
    parameters: {
        taxonomy: 'a00000000000000001' // Replace with your taxonomy Id from your TaxonomyBundle
    },
    bundle: { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
        taxonomyID: 'a00000000000000001',
        tagDefinitionID: 'a01000000000000000'
    },
    requestFlags: {},
    contentId: 'a00000000000000000' // Replace contentId with the content version Id
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'addTagToContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // addTagToContent Request
 
You cannot tag a content item with the root node of a taxonomy.
 
You must have a lock on an unpublished piece of content to add a taxonomy tag to it.

addTagsToContent

This method adds the tagPaths to the specified content ID.

Parameters

  • parameters: Map<String, String>, The parameters map must contain a key of taxonomy  with a value of a Taxonomy Id.
  • contentId: String, The content ID where the tags should be added.
  • categories: List<TaxonomyBundle>, The list of TaxonomyBundles that will be added to the content.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.parameters = new Map<String, String>{'taxonomy' => 'a00000000000000001'}; // Replace with your taxonomy Id
taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

TaxonomyBundle bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
bundle.taxonomyID = 'a00000000000000001';
bundle.tagDefinitionID = 'a01000000000000000';

taxonomyRequest.categories = new List<TaxonomyBundle>{bundle};

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'addTagsToContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to add the tags to the content.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Tags were added to the content successfully.' on success

JavaScript Request

var apiRequest = {
    parameters: {
        taxonomy: 'a00000000000000001' // Replace with your taxonomy Id
    },
    categories: [
        { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
            taxonomyID: 'a00000000000000001',
            tagDefinitionID: 'a01000000000000000',
            depth: 1
        }
    ],
    contentId: 'a00000000000000000', // Replace contentId with the content version Id
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'addTagsToContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // addTagsToContent Request
 
You cannot tag a content item with the root node of a taxonomy.
 
You must have a lock on an unpublished piece of content to add taxonomy tags to it.

getChildren

This method returns a TaxonomyBundle representing a node in the taxonomy that exposes the full structure of the taxonomy beneath this node.

Parameters

  • requestFlags: Map<String, Boolean>, The requestFlags must contain a map with a key of fullTree and a value of true.
  • bundle: TaxonomyBundle, The TaxonomyBundle used to retrieve the child nodes.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.requestFlags.put('fullTree', true);

taxonomyRequest.bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
taxonomyRequest.bundle.taxonomyID = 'a00000000000000000';

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'getChildren');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to get the children for the taxonomy.');
}
if (apiResponse.type != 'TaxonomyBundle') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and TaxonomyBundle
System.Debug(apiResponse.message); // Outputs 'The taxonomy structure' on success

JavaScript Request

var apiRequest = {
    bundle: { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
        taxonomyID: 'a00000000000000000'
    },
    requestFlags: {
        fullTree: true
    }
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'getChildren',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // renameNode Request
 
The languageMapOfPaths property in a taxonomy bundle is only populated if the taxonomy is published.

getTagsOnContent

This method retrieves all tags on the specified content.

Parameters

  • contentId: String, The content ID used  to retrieve the tags.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();

taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'getTagsOnContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'my_site'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);
JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to get the tags for the content.');
}
if (apiResponse.type != 'List<TaxonomyBundle>') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and List<TaxonomyBundle>
System.Debug(apiResponse.message); // Outputs 'Retrieved tags for content' on success

JavaScript Request

var apiRequest = {
    requestFlags: {},
    contentId: 'a00000000000000000' // Replace contentId with the content version Id
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'getTagsOnContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // getTagsOnContent Request

getTaxonomies

This method retrieves all the taxonomy roots for the current site.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'getTaxonomies');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to get the taxonomies for the site.');
}
if (apiResponse.type != 'List<TaxonomyBundle>') {
    throw new APIException('Unexpected result from Taxonomy API.');
}
 
System.Debug(response); // Outputs response and List of TaxonomyBundles
System.Debug(apiResponse.message); // Outputs 'The taxonomy root nodes for the site_name site.' on success

JavaScript Request

var apiRequest = {
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'getTaxonomies',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // getTaxonomies Request
 
The languageMapOfPaths property in a taxonomy bundle is only populated if the taxonomy is published.

removeTagFromContent

This method removes the tagPath from the specified content ID.

Parameters

  • parameters: Map<String, String>, The parameters map must contain a key of taxonomy  with a value of a Taxonomy ID.
  • contentId: String, The content ID where the tag should be removed.
  • bundle: TaxonomyBundle, The TaxonomyBundle that will be removed from the content.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.parameters = new Map<String, String>{'taxonomy' => 'a00000000000000001'}; // Replace with your taxonomy Id
taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

taxonomyRequest.bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
taxonomyRequest.bundle.taxonomyID = 'a00000000000000001';
taxonomyRequest.bundle.tagDefinitionID = 'a01000000000000000';

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'removeTagFromContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to reomve the tag from the content.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Tag was removed from the content successfully.' on success

JavaScript Request

var apiRequest = {
    parameters: {
        taxonomy: 'a00000000000000001' // Replace with your taxonomy Id from your TaxonomyBundle
    },
    bundle: { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
        taxonomyID: 'a00000000000000001',
        tagDefinitionID: 'a01000000000000000'
    },
    requestFlags: {},
    contentId: 'a00000000000000000' // Replace contentId with the content version Id
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'removeTagFromContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // removeTagFromContent Request
 
You must have a lock on an unpublished piece of content to remove a taxonomy tag from it.

removeTagsFromContent

This method removes the tagPaths from the specified content ID.

Parameters

  • parameters: Map<String, String>, The parameters map must contain a key of taxonomy  with a value of a Taxonomy ID.
  • contentId: String, The content ID where the tags should be removed.
  • categories: List<TaxonomyBundle>, The list of TaxonomyBundles that will be removed from the content.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.parameters = new Map<String, String>{'taxonomy' => 'a00000000000000001'}; // Replace with your taxonomy Id
taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

TaxonomyBundle bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
bundle.taxonomyID = 'a00000000000000001';
bundle.tagDefinitionID = 'a01000000000000000';
bundle.depth = 1;

taxonomyRequest.categories = new List<TaxonomyBundle>{bundle};

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'removeTagsFromContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to remove the tags from the content.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Tags were removed from the content successfully.' on success

JavaScript Request

var apiRequest = {
    parameters: {
        taxonomy: 'a00000000000000001' // Replace with your taxonomy Id
    },
    categories: [
        { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
            taxonomyID: 'a00000000000000001',
            tagDefinitionID: 'a01000000000000000',
            depth: 1
        }
    ],
    contentId: 'a00000000000000000', // Replace contentId with the content version Id
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'removeTagsFromContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // removeTagsFromContent Request
 
You must have a lock on an unpublished piece of content to remove taxonomy tags from it.

renameNode

This method renames the node based on the specified TaxonomyBundle languages.

Parameters

  • bundle: TaxonomyBundle, The TaxonomyBundle where the node will be renamed.
  • bundle.languageMapOfTagNames: Map<String, String>, A map with keys of language codes and values of the new node name.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();

taxonomyRequest.bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
taxonomyRequest.bundle.taxonomyID = 'a00000000000000000';
taxonomyRequest.bundle.tagDefinitionID = 'a01000000000000000';

// Replace renamed_value with the value you intend to rename the node to. Additional languages can be translated as required
taxonomyRequest.bundle.languageMapOfTagNames = new Map<String, String>{'en_US' => 'renamed_value'};

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'renameNode');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to rename the taxonomy node.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Successfully renamed the node.' on success

JavaScript Request

var apiRequest = {
    bundle: { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
        taxonomyID: 'a00000000000000000',
        tagDefinitionID: 'a01000000000000000',
        languageMapOfTagNames: { // Replace renamed_value with the value you intend to rename the node to. Additional languages can be translated as required
            en_US: 'Level 1-1a-test123'
        }
    },
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'renameNode',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // renameNode Request
 
The languageMapOfPaths parameter is ignored. If an existing name for a given language is not explicitly overriden, it will not be erased.
 
You must have a lock on an unpublished taxonomy to rename nodes in it.

setTagsOnContent

This method sets all tags on the specified content.

Parameters

  • parameters: Map<String, String>, The parameters map must contain a key of taxonomy  with a value of a Taxonomy ID.
  • contentId: String, The content ID to set the tag on.
  • categories: List<TaxonomyBundle>, The list of TaxonomyBundles that will be set on the content.

Apex Request

TaxonomyAPIRequest taxonomyRequest = new TaxonomyAPIRequest();
taxonomyRequest.parameters = new Map<String, String>{'taxonomy' => 'a00000000000000001'}; // Replace with your taxonomy Id
taxonomyRequest.contentId = 'a00000000000000000'; // Replace contentId with the content version Id

TaxonomyBundle bundle = new TaxonomyBundle(); // Here we are simulating having already retrieved an actual existing TaxonomyBundle
bundle.taxonomyID = 'a00000000000000001';
bundle.tagDefinitionID = 'a01000000000000000';
bundle.originID = 'a00000000000000001';
bundle.languageMapOfTagNames = new Map<String, String>{'en_US' => 'Level 1-1a'};
bundle.languageMapOfPaths = new Map<String, String>{'en_US' => '/Test Taxonomy 1/Level 1-1a'};
bundle.depth = 1;

taxonomyRequest.categories = new List<TaxonomyBundle>{bundle};

Map<String, String> parameters = new Map<String, String>();
parameters.put('service', 'TaxonomyAPI');
parameters.put('action', 'setTagsOnContent');
parameters.put('taxonomyRequest', json.serialize(taxonomyRequest));
parameters.put('sname', 'site_name'); // Replace site_name with the name of your OrchestraCMS site
parameters.put('apiVersion', '5.0');

String response = cms.ServiceEndPoint.doActionApex(parameters);

JSONMessage.APIResponse apiResponse = (JSONMessage.APIResponse) json.deserialize(response, JSONMessage.APIResponse.class);

if (!apiResponse.isSuccess) {
    throw new APIException('Unable to set the tags on the content.');
}
if (apiResponse.type != 'Message') {
    throw new APIException('Unexpected result from Taxonomy API.');
}

System.Debug(response); // Outputs response and Message
System.Debug(apiResponse.message); // Outputs 'Tags were set on the content successfully.' on success

JavaScript Request

var apiRequest = {
    parameters: {
        taxonomy: 'a00000000000000001' // Replace with your taxonomy Id
    },
    categories: [
        { // Here we are simulating having already retrieved an actual existing TaxonomyBundle
            taxonomyID: 'a00000000000000001',
            originID: 'a00000000000000001',
            tagDefinitionID: 'a01000000000000000',
            depth: 1,
            languageMapOfTagNames: {
                en_US: 'Level 1-1a'
            },
            languageMapOfPaths: {
                en_US: '/Test Taxonomy 1/Level 1-1a'
            }
        }
    ],
    contentId: 'a00000000000000000', // Replace contentId with the content version Id
    requestFlags: {}
};
var response = '';
var data = {
    service: 'TaxonomyAPI',
    action: 'setTagsOnContent',
    taxonomyRequest: JSON.stringify(apiRequest),
    apiVersion: '5.0'
};
// Handle response of a successful ajax call
var callBackHandler = function(json, Success) {
    var jsonResponse = JSON.parse(json);
    console.log(jsonResponse);
}
var options = {
    cb: callBackHandler,
    cbHandlerOnComplete: function(textStatus){}, // Handle response on complete
    readonly: false // Whether it is a read only call
};
doServiceRequest(data, options); // setTagsOnContent Request
 
You cannot tag a content item with the root node of a taxonomy.
 
You must have a lock on an unpublished piece of content to set taxonomy tags on it.

JSON-Serialized Response Examples

List<TaxonomyBundle> Example

{
    "type": "List<TaxonomyBundle>",
    "transactionId": null,
    "timeNow": "2017-06-26T00:00:00.000Z",
    "responseObject": [{
        "taxonomyID": "a00000000000000000",
        "tagID": "a00000000000000000",
        "tagDefinitionID": "a01000000000000000",
        "originID": "a00000000000000000",
        "languageMapOfTagNames": {
            "fr": "Test Taxonomy 1",
            "en_US": "Test Taxonomy 1"
        },
        "languageMapOfPaths": {
            "fr": "/Test Taxonomy 1",
            "en_US": "/Test Taxonomy 1"
        },
        "depth": 0,
        "children": []
    }],
    "moreResults": false,
    "message": "The taxonomy root nodes for the site_name site.",
    "isSuccess": true,
    "error": null
}

TaxonomyBundle Example

{
    "type": "TaxonomyBundle",
    "transactionId": null,
    "timeNow": "2017-06-26T00:00:00.000Z",
    "responseObject": {
        "taxonomyID": "a00000000000000000",
        "tagID": "a00000000000000000",
        "tagDefinitionID": null,
        "originID": null,
        "languageMapOfTagNames": {
            "en_US": "Test Taxonomy 1"
        },
        "languageMapOfPaths": {
            "en_US": "/Test Taxonomy 1"
        },
        "depth": 0,
        "children": [{
            "taxonomyID": "a00000000000000000",
            "tagID": "a01000000000000000",
            "tagDefinitionID": "a02000000000000000",
            "originID": null,
            "languageMapOfTagNames": {
                "en_US": "Level 1-1a"
            },
            "languageMapOfPaths": {
                "en_US": "/Test Taxonomy 1/Level 1-1a"
            },
            "depth": 1,
            "children": [{
                "taxonomyID": "a00000000000000000",
                "tagID": "a01000000000000002",
                "tagDefinitionID": null,
                "originID": null,
                "languageMapOfTagNames": {
                    "en_US": "Level2-1a"
                },
                "languageMapOfPaths": {
                    "en_US": "/Test Taxonomy 1/Level 1-1a/Level2-1a"
                },
                "depth": 2,
                "children": []
            }, {
                "taxonomyID": "a00000000000000000",
                "tagID": "a01000000000000003",
                "tagDefinitionID": null,
                "originID": null,
                "languageMapOfTagNames": {
                    "en_US": "Level2-1b"
                },
                "languageMapOfPaths": {
                    "en_US": "/Test Taxonomy 1/Level 1-1a/Level2-1b"
                },
                "depth": 2,
                "children": []
            }]
        }, {
            "taxonomyID": "a00000000000000000",
            "tagID": "a01000000000000001",
            "tagDefinitionID": null,
            "originID": null,
            "languageMapOfTagNames": {
                "en_US": "Level 1-2a"
            },
            "languageMapOfPaths": {
                "en_US": "/Test Taxonomy 1/Level 1-2a"
            },
            "depth": 1,
            "children": []
        }]
    },
    "moreResults": false,
    "message": "The taxonomy structure",
    "isSuccess": true,
    "error": null
}

Message Example

{
    "type": "Message",
    "transactionId": null,
    "timeNow": "2017-06-26T00:00:00.000Z",
    "responseObject": null,
    "moreResults": false,
    "message": "Tags were added to the content successfully.",
    "isSuccess": true,
    "error": null
}