<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help getting to the /computer API endpoint in Endpoint Privilege Manager (EPM) Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406582#M6104</link>
    <description>&lt;CODE&gt;import csv
import requests
import getpass
import urllib3
&amp;nbsp;
# ----------------------------
# Suppress SSL Warnings
# ----------------------------
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
&amp;nbsp;
# ----------------------------
# Configuration
# ----------------------------
csv_path = r"C:\Temp\ComputerName.csv"   # Change to your file path
api_version = "25.3.2"
set_id = "moreblahblah-blah"
base_url = f"https://BLAHBLAH.epm.cyberark.com/EPM/API/Sets/{set_id}"
auth_url = "https://login.epm.cyberark.com/EPM/API/Auth/EPM/Logon"  # US Dispatcher
&amp;nbsp;
# ----------------------------
# Prompt for Credentials
# ----------------------------
username = input("Enter your EPM username: ")
password = getpass.getpass("Enter your EPM password (input hidden): ")
&amp;nbsp;
# ----------------------------
# Authenticate with Dispatcher
# ----------------------------
auth_payload = {
    "username": username,
    "password": password,
    "tenantId": tenant_id,
    "ApplicationID": "BlahApplication"
}
&amp;nbsp;
headers = {
    "Content-Type": "application/json"
}
&amp;nbsp;
auth_response = requests.post(auth_url, json=auth_payload, headers=headers, verify=False)
&amp;nbsp;
print("\nAuth Response Status code:", auth_response.status_code)
print("Auth Response Body:", auth_response.text)
&amp;nbsp;
if auth_response.status_code == 200:
    auth_data = auth_response.json()
    token = auth_data.get("EPMAuthenticationResult")
    headers["Authorization"] = f"Bearer {token}"
    print(f"Authenticated. ApplicationID: {auth_data.get('ApplicationID')}")
else:
    raise Exception(f"Failed to authenticate to EPM: {auth_response.status_code} - {auth_response.text}")
#print(token)
&amp;nbsp;
# ----------------------------
# Read Computers from CSV
# ----------------------------
with open(csv_path, mode='r', newline='', encoding='utf-8-sig') as file:
    reader = csv.DictReader(file)
    computers_to_delete = [
        row['ComputerName'].strip().upper()
        for row in reader
        if row.get('ComputerName')
    ]
&amp;nbsp;
# ----------------------------
# Get Computers in the Set
# ----------------------------
computers_url = f"{base_url}/Computers"
&amp;nbsp;
computers_response = requests.get(computers_url, headers=headers)
&amp;nbsp;
if computers_response.status_code != 200:
    raise Exception(f"Failed to retrieve computers: {computers_response.status_code} - {computers_response.text}")
&amp;nbsp;
computers = computers_response.json().get("Computers", [])
&amp;nbsp;
# Map: ComputerName → list of AgentIDs
name_to_agent_ids = {}
for comp in computers:
    name = comp["ComputerName"].upper()
    agent_id = comp["AgentID"]
    name_to_agent_ids.setdefault(name, []).append(agent_id)
&amp;nbsp;
# ----------------------------
# Delete Matching Computers
# ----------------------------
for comp_name in computers_to_delete:
    agent_ids = name_to_agent_ids.get(comp_name)
    if agent_ids:
        for agent_id in agent_ids:
            delete_url = f"{base_url}/Computers/{agent_id}"
            delete_response = requests.delete(delete_url, headers=headers, verify=False)
&amp;nbsp;
            if delete_response.status_code == 200:
                print(f"Deleted {comp_name} (AgentID: {agent_id})")
            else:
                print(f"Failed to delete {comp_name} (AgentID: {agent_id}): {delete_response.status_code} - {delete_response.text}")
    else:
        print(f"{comp_name} not found in Set '{set_name}'.")&lt;/CODE&gt;&lt;P&gt;Anyone know what is wrong my python script? Getting an error "&amp;nbsp;&amp;nbsp;raise Exception(f"Failed to retrieve computers: {computers_response.status_code} - {computers_response.text}")&lt;/P&gt;&lt;P&gt;Exception: Failed to retrieve computers: 404 - [{"ErrorCode":"EPM000004E","ErrorMessage":"The requested resource could not be found, or the user does not have permissions for this resource."}]"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Apr 2025 13:56:29 GMT</pubDate>
    <dc:creator>hdacosta</dc:creator>
    <dc:date>2025-04-25T13:56:29Z</dc:date>
    <item>
      <title>Help getting to the /computer API endpoint</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406582#M6104</link>
      <description>&lt;CODE&gt;import csv
import requests
import getpass
import urllib3
&amp;nbsp;
# ----------------------------
# Suppress SSL Warnings
# ----------------------------
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
&amp;nbsp;
# ----------------------------
# Configuration
# ----------------------------
csv_path = r"C:\Temp\ComputerName.csv"   # Change to your file path
api_version = "25.3.2"
set_id = "moreblahblah-blah"
base_url = f"https://BLAHBLAH.epm.cyberark.com/EPM/API/Sets/{set_id}"
auth_url = "https://login.epm.cyberark.com/EPM/API/Auth/EPM/Logon"  # US Dispatcher
&amp;nbsp;
# ----------------------------
# Prompt for Credentials
# ----------------------------
username = input("Enter your EPM username: ")
password = getpass.getpass("Enter your EPM password (input hidden): ")
&amp;nbsp;
# ----------------------------
# Authenticate with Dispatcher
# ----------------------------
auth_payload = {
    "username": username,
    "password": password,
    "tenantId": tenant_id,
    "ApplicationID": "BlahApplication"
}
&amp;nbsp;
headers = {
    "Content-Type": "application/json"
}
&amp;nbsp;
auth_response = requests.post(auth_url, json=auth_payload, headers=headers, verify=False)
&amp;nbsp;
print("\nAuth Response Status code:", auth_response.status_code)
print("Auth Response Body:", auth_response.text)
&amp;nbsp;
if auth_response.status_code == 200:
    auth_data = auth_response.json()
    token = auth_data.get("EPMAuthenticationResult")
    headers["Authorization"] = f"Bearer {token}"
    print(f"Authenticated. ApplicationID: {auth_data.get('ApplicationID')}")
else:
    raise Exception(f"Failed to authenticate to EPM: {auth_response.status_code} - {auth_response.text}")
#print(token)
&amp;nbsp;
# ----------------------------
# Read Computers from CSV
# ----------------------------
with open(csv_path, mode='r', newline='', encoding='utf-8-sig') as file:
    reader = csv.DictReader(file)
    computers_to_delete = [
        row['ComputerName'].strip().upper()
        for row in reader
        if row.get('ComputerName')
    ]
&amp;nbsp;
# ----------------------------
# Get Computers in the Set
# ----------------------------
computers_url = f"{base_url}/Computers"
&amp;nbsp;
computers_response = requests.get(computers_url, headers=headers)
&amp;nbsp;
if computers_response.status_code != 200:
    raise Exception(f"Failed to retrieve computers: {computers_response.status_code} - {computers_response.text}")
&amp;nbsp;
computers = computers_response.json().get("Computers", [])
&amp;nbsp;
# Map: ComputerName → list of AgentIDs
name_to_agent_ids = {}
for comp in computers:
    name = comp["ComputerName"].upper()
    agent_id = comp["AgentID"]
    name_to_agent_ids.setdefault(name, []).append(agent_id)
&amp;nbsp;
# ----------------------------
# Delete Matching Computers
# ----------------------------
for comp_name in computers_to_delete:
    agent_ids = name_to_agent_ids.get(comp_name)
    if agent_ids:
        for agent_id in agent_ids:
            delete_url = f"{base_url}/Computers/{agent_id}"
            delete_response = requests.delete(delete_url, headers=headers, verify=False)
&amp;nbsp;
            if delete_response.status_code == 200:
                print(f"Deleted {comp_name} (AgentID: {agent_id})")
            else:
                print(f"Failed to delete {comp_name} (AgentID: {agent_id}): {delete_response.status_code} - {delete_response.text}")
    else:
        print(f"{comp_name} not found in Set '{set_name}'.")&lt;/CODE&gt;&lt;P&gt;Anyone know what is wrong my python script? Getting an error "&amp;nbsp;&amp;nbsp;raise Exception(f"Failed to retrieve computers: {computers_response.status_code} - {computers_response.text}")&lt;/P&gt;&lt;P&gt;Exception: Failed to retrieve computers: 404 - [{"ErrorCode":"EPM000004E","ErrorMessage":"The requested resource could not be found, or the user does not have permissions for this resource."}]"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Apr 2025 13:56:29 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406582#M6104</guid>
      <dc:creator>hdacosta</dc:creator>
      <dc:date>2025-04-25T13:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help getting to the /computer API endpoint</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406583#M6105</link>
      <description>&lt;P&gt;Hi @Henrique da Costa​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems base_url or set_id is incorrect or in case authenticating user doesn't have the right permissions to view endpoints in that set, you'll also get this error. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Apr 2025 03:48:33 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406583#M6105</guid>
      <dc:creator>M.Vora780263</dc:creator>
      <dc:date>2025-04-26T03:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help getting to the /computer API endpoint</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406584#M6106</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;After authentication you provide the token as bearer while it should be basic&lt;/P&gt;&lt;P&gt;Try Authorization: basic &amp;lt;TOKEN&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;https://docs.cyberark.com/epm/latest/en/content/webservices/getcomputers.htm#Headerparameters&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice day.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2025 08:12:43 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406584#M6106</guid>
      <dc:creator>igor.bezverhi</dc:creator>
      <dc:date>2025-04-27T08:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help getting to the /computer API endpoint</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406585#M6107</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Try omitting the dollar sign, keep only the question mark&lt;/P&gt;&lt;P&gt;...Computers?limit=3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 15:36:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406585#M6107</guid>
      <dc:creator>igor.bezverhi</dc:creator>
      <dc:date>2025-04-28T15:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help getting to the /computer API endpoint</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406586#M6108</link>
      <description>&lt;P&gt;OMG! That was freaking it. Got everything to work that way I needed. Thank you so much. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 15:41:34 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/help-getting-to-the-computer-api-endpoint/m-p/1406586#M6108</guid>
      <dc:creator>hdacosta</dc:creator>
      <dc:date>2025-04-28T15:41:34Z</dc:date>
    </item>
  </channel>
</rss>

