We’ve migrated our documentation to a new site, which means some URLs have changed.
Audience

Enabling the Standard Piano Audience Taxonomy

The standard taxonomy can be enabled using cx.py as shown below (unix version on the first line, then Windows version on the next):

$ python cx.py /site/group/update '{"siteGroupId":"<YOUR SITE GROUP ID>", "useStandardTaxonomy":true, "admin":true}'
> python cx.py /site/group/update "{\"siteGroupId\":\"<YOUR SITE GROUP ID>\", \"useStandardTaxonomy\":true, \"admin\":true}"

Another alternative is to run the Python 3.x script below, Only Cxense representative will have sufficient credentials for running the script or the commands above.

_username     = "<YOUR CXENSE USER ID>"
_secret       = "<YOUR CXENSE API KEY>"
_siteGroupId  = "<YOUR SITE GROUP ID>"
    
import json, base64, datetime, hmac, hashlib, http.client
    
def cxApi(path, obj):
    date = datetime.datetime.utcnow().isoformat() + "Z"
    signature = hmac.new(_secret.encode('utf-8'), date.encode('utf-8'), digestmod=hashlib.sha256).hexdigest()
    headers = {"X-cXense-Authentication": "username=%s date=%s hmac-sha256-hex=%s" % (_username, date, signature)}
    connection = http.client.HTTPSConnection("api.cxense.com", 443)
    connection.request("POST", path, json.dumps(obj), headers)
    response = connection.getresponse()
    status = response.status
    responseObj = json.loads(response.read().decode('utf-8'))
    connection.close()
    return status, responseObj
  
def errorHandling(status, response, message):
    if status != 200:
        raise Exception("%s (http status = %s, error details: '%s')" % (message, status, response['error']))
 
def hasCustomerPrefix(siteGroupId):
    status, response = cxApi('/site/group', {"siteGroupId":siteGroupId, "admin":True})
    errorHandling(status, response, "Failed to obtain site group information")
    if 'prefix' in response['siteGroups'][0]:
        return True
    return False
    
def enableStandardTaxonomy(siteGroupId):
    status, response = cxApi('/site/group/update', {"siteGroupId":siteGroupId, "useStandardTaxonomy":True, "admin":True})
    errorHandling(status, response, "Failed to enable the default taxonomy")
  
if hasCustomerPrefix(_siteGroupId):
    enableStandardTaxonomy(_siteGroupId)
else:
    print('The site group lacks a custom prefix, not possible to enable taxonomy without one')

Last updated: