cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Daniel_S
Reliable Contributor
Reliable Contributor
Report Inappropriate Content
Message 1 of 5

WebAPI tagging via ID not working

Jump to solution

Hey fellas,

I have a Powershell Script that´s doing some tasks on a ePO 5.9.1.

One of these parts is tagging systems with a supplied TAG.

We were successful using it with systemnames but now are in the need of using the Agent GUID.

According to the API itselt it says:

OK:
system.applyTag names tagName
Assigns the given tag to a supplied list of systems. System list can contain
names, IP addresses or IDs.
Requires Tag use permission
Parameters:
 [names (param 1) | ids] - You need to either supply the "names" with a
comma-separated list of names/ip addresses or a comma-separated list of "IDs".
 [tagName (param 2) | tagID] - You need to either supply the tag name or the tag
ID.

So we can either suppy the systems with names=SYSTEMNAME or with ids=ID.

As I found no other IDs and the GUID makes absolutely sense in the meaning of being unique I asume that the GUID is meant here.

https://ePO-IP:Port/remote/system.applyTag?ids=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&tagName=test

I always get the following error:

Error 0 :
For input string: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"

 The string is correct and when searched in ePO leads me to the corresponding system.

Doing the part manually direct in the browser gives me the same result: Error.

Any ideas?

Best regards
Dan
2 Solutions

Accepted Solutions
cdinet
Employee
Employee
Report Inappropriate Content
Message 2 of 5

Re: WebAPI tagging via ID not working

Jump to solution
ID would refer to the ID of the system in the epoleafnode table in the database, not the agent guid.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

View solution in original post

JoeBidgood
Employee
Employee
Report Inappropriate Content
Message 3 of 5

Re: WebAPI tagging via ID not working

Jump to solution

To add to this, the ID you want can be found using the system.find command: the ID is returned as the "System Location" value.

View solution in original post

4 Replies
cdinet
Employee
Employee
Report Inappropriate Content
Message 2 of 5

Re: WebAPI tagging via ID not working

Jump to solution
ID would refer to the ID of the system in the epoleafnode table in the database, not the agent guid.

Was my reply helpful?
If this information was helpful in any way or answered your question, will you please select Accept as Solution in my reply and together we can help other members?

JoeBidgood
Employee
Employee
Report Inappropriate Content
Message 3 of 5

Re: WebAPI tagging via ID not working

Jump to solution

To add to this, the ID you want can be found using the system.find command: the ID is returned as the "System Location" value.

spederse
Employee
Employee
Report Inappropriate Content
Message 4 of 5

Re: WebAPI tagging via ID not working

Jump to solution

Here is an URL example where API executeQuery is pulling the information ready for the applyTag API.
It is the "EPOLeafNode.AutoID" which can be used for tagging based on "ids". The result is provide as json

https://<epo>:8443/remote/core.executeQuery?target=EPOLeafNode&select=(select%20EPOLeafNode.AutoID%20EPOLeafNode.NodeName%20EPOLeafNode.LastUpdate%20EPOLeafNode.AgentGUID%20EPOComputerProperties.UserName%20EPOLeafNode.Tags%20EPOBranchNode.NodeTextPath2%20EPOComputerProperties.UserProperty2%20EPOComputerProperties.UserProperty3%20EPOProdPropsView_UDLP.productversion%20)&where=(+and+(+version_ge+EPOProdPropsView_UDLP.productversion+%2211%22+)+(+eq+EPOComputerProperties.OSPlatform+%22Workstation%22)))&:output=json

spederse
Employee
Employee
Report Inappropriate Content
Message 5 of 5

Re: WebAPI tagging via ID not working

Jump to solution

Example of PowerShell function invoking the ePO API

function g_Get_System_Tree_info_from_ePO {
# Ask for cred if there is not coded credentials
if (($username -eq "user") -or ($username.Length -lt 1))
{
    $cred = Get-Credential #Ask for ePO credentials
}

$ePO_command = '/remote/core.executeQuery?' 
# Pull all systems
#$options = 'target=EPOLeafNode&select=(select EPOLeafNode.NodeName EPOLeafNode.LastUpdate EPOLeafNode.AgentGUID EPOComputerProperties.UserName EPOLeafNode.Tags EPOBranchNode.NodeTextPath2 EPOComputerProperties.UserProperty2 EPOComputerProperties.UserProperty3 )&:output=json'

# Pull only systems with DLP installed and Workstations
$options = 'target=EPOLeafNode&select=(select%20EPOLeafNode.AutoID%20EPOLeafNode.NodeName%20EPOLeafNode.LastUpdate%20EPOLeafNode.AgentGUID%20EPOComputerProperties.UserName%20EPOLeafNode.Tags%20EPOBranchNode.NodeTextPath2%20EPOComputerProperties.UserProperty2%20EPOComputerProperties.UserProperty3%20EPOProdPropsView_UDLP.productversion%20)&where=(+and+(+version_ge+EPOProdPropsView_UDLP.productversion+%2211%22+)+(+eq+EPOComputerProperties.OSPlatform+%22Workstation%22+)+)+)&:output=json'
$URL = $URL_ePO + $ePO_command + $options
$URL
#Working 
#$Result = Invoke-RestMethod -Uri $URL -Credential $cred 
$Result = Invoke-RestMethod  -Uri $URL -Credential $cred -Method GET -Headers $headers -Body $body -ContentType 'application/json'

# Write the Result to a file
$Short = $Result.Replace('OK:','')
$Short | out-file -filepath ($g_working_dir+'\ePO_result.txt')
}
Tags (2)
You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use our Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from product experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by employees.
Join the Community
Join the Community