Add a Tag to the content system

Adds a content Tag to the system so it can then be applied to content items

Method

/API2/content/addTag
  • API Section: /API2/content
  • API Version: 2.0
  • From Release: 2018.5
  • Usage: REST API only via POST actions.
  • Usage by:
    • Enterprise Admin

Method Signature

Input Parameters

Name

tagData

Object Type

TagData

Description

The tag object used to capture a tag’s settings.

Output Response

Successful Result Code

200

Response Type

ModifiedItemsResult

Description of Response Type

Generic API response object with success or failure flag and related messages.

Notes

Tags need to be added to the system first before applying them to items. Use this method to add them, then use ‘addTagToItem’ to apply to a content item.

Examples

Content and Tag Operations (JavaScript):

This example demonstrates how to find item's and the manipulation of content tags.

The example uses API authentication driven from JavaScript. See Authentication APIs for alternatives.

// URL of the Pyramid installation and the path to the API 2.0 REST methods
var pyramidURL = "http://mysite.com/api2/";

// step 1: authenticate admin account and get token // NOTE: callApi method is a generic REST method shown below. let token = callApi(“auth/authenticateUser”,{ “data”:{ “userName”:“adminUser”, “password”:“abc123!” } },false);

//step 2: add a tag to the system let addedTag = callApi(“content/addTag “,{ “tagData”: { “tagDescription”:tagName, “tagType”:0 }, “auth”: token });

let tagId = addedTag.data.modifiedList[0].id;

//step 2: find/search for a Discover item called “sales figures” let dataDiscovery = callApi(“content/findContentItem”,{ “searchParams”: { “searchString”: “sales figures”, “filterTypes”: [3], “searchMatchType”: 2, “searchRootFolderType”:0 }, “auth”: token // admin token generated above });

let itemId = dataDiscovery.data[0].id;

//step 3: bind the new tag to this report let itemIds = callApi(“content/addTagToItem “,{ “tagUsageApiData”: { “itemId”:itemId, “tagId”:tagId }, “auth”: token });

//step 4: get a specific tag object using its tag id let getTag = callApi(“content/getTag”,{ “tagId”: tagId, “auth”: token })

//step 5: remove the tag from a specific content item let removeTagFromItem = callApi(“content/removeTagFromItem “,{ “tagUsageApiData”: { “itemId”:itemId, “tagId”:tagId }, “auth”: token });

//step 6: delete the tag let deleteTag = callApi(“content/deleteTag “,{ “tagId”: tagId, “auth”: token });

//step 7: permanently delete the content item let purgeContentItems = callApi(“content/purgeContentItems”,{ “itemIds”:[folderCreation.modifiedList[0].id], “auth”: token });

// ##### optional generic logging method for debugging ############## function log(msg){ document.write(msg); console.log(msg); }

// ##### generic REST API calling method ############## function callApi(path,data,parseResult=true){ var xhttp = new XMLHttpRequest(); xhttp.open(“POST”, pyramidURL+path, false); xhttp.send(JSON.stringify(data)); if(parseResult){ return JSON.parse(xhttp.responseText); }else{ return xhttp.responseText; } }

	</code></pre></details>