Purpose: This is an API sample code walkthrough for how to automate assigning a tag, or tags, to one or more assets (I cover the Postman method in this document).
Description: This example follows along with the community post on tagging examples (Asset Tagging API Examples ). Please feel free to post your comments/questions for follow up conversation.
Step 1: Get a list of host IDs
- Run a query for "All IP in subscription"
- If you do not have the "All IP in subscription" tag you can create one by either creating an asset group with all assets or by creating a tag with a QID that all assets have. Ex: You can use an information gathered QID for host time. This should function as a workaround once the tag has been completely assigned out. Note: It might take a couple of minutes to assign out if you selected the re-evaluate on rule save option.
- If there is another tag you want to use, replace the string with your tag name and skip to step 2 below.
- Parse through the list to narrow it down to just the IPs needed, you will only need their HostIDs
Step 2: Add tag(s) to list of host IDs
- Now that you have a list of the HostAsset IDs (found in XML response under: \data\HostAsset\id in XMLPATH or found in UI under "Asset ID") that you want to add tags to you can follow along with the community post here: Asset Tagging API Examples