Our Blog > Blog Detail

Web Content Viewer- Asponte Custom Skin


More on Leveraging the Portal Tagging and Rating REST API - Deleting a Tag - it takes two steps

  • Created By: Maria Rauba
  • Updated: July 27, 2016
  • Tags: tagging, rest, tag, api, oid

Chris Knight recently wrote a blog entry about the Portal Tagging and Rating REST API  in regards to adding a tag.  I implemented this add capability, but I also needed to delete a tag using this REST API.

The documentation simply says:

To delete a tag, send an HTTP DELETE against the URI uri tm:oid:oid_of_a_tag.

But how do you get the "oid_of_a_tag"?  I could not find any documentation on that.  So I decided to roll up my sleeves and used my browser's developer tools to analyze the network requests sent when deleting tags in the Suggested Links tagging feature.

When you delete a tag, you are deleting the instance of the tag for a particular piece of content.  So here is what I discovered... to get the OID for the tag for a particular piece of content,  you have to use the rmparam parameter with the 'rm:wcm:oid' similar to how Chris needed that to add a tag, and the tm:name request which is sort of described here.  Here is an example AJAX request:

      var tagOID
      //Lookup the tag for this content item to get the oid
        type: "GET",
        url: "/wps/contenthandler?uri=tm:name:"+tagName,
        data: {
        async: false,
        success: function(data) {      
          console.log("success got info for:" +tagName);
          //There will be only one entry element
          entry = $(data).find("atom\\:entry,entry")
          tagOID = entry.find("atom\\:id").text();
          if (!tagOID) {
            console.log("atom:id was empty");
            tagOID = entry.find("id").text();
          console.log("got tag oid: "+ tagOID);      
        error: function(data) {
          console.log("ERROR getting info for!!" +tagName);

So then once you have the tagOID (which will be of the form "tm:oid:ZCI_MAC41CG0J0BP70ALPUD6040GN4", then you can issue the DELETE request:

      // Send the data using DELETE - the tagOID from previous step will be of the form:
      if (tagOID) {
          type: "DELETE",
          url: "/wps/mycontenthandler?uri="+tagOID,
          xhrFields: {
            withCredentials: true
          success: function(data) {
            console.log("success for delete!!" +data);
          error: function(xhr, status, error) {         
            console.log("ERROR deleting!! ResponseText:" +xhr.responseText+ "xhr.status: "+xhr.status);

Contact Form- Asponte Custom Skin


Contact Us


Call Us 888-926-9434
Complementary Content