- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
11-23-2023 09:05 PM
I'm trying to call the EPM API using Python Requests, but it doesn't work. What is wrong with the script below? I created it with reference to the following document.
https://docs.cyberark.com/EPM/23.11.0/en/Content/WebServices/GetDetailedRawEvents.htm
The Python script is below.
#####################################
import requests
import json
token = "<Token that have been researched in advance>"
setID = "<SetID that have been researched in advance>"
url = "https://jp.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
headers = {"Content-Type": "application/json", "Authorization": "basic " + token}
data = {"filter": "fileName CONTAINS \"notepad++\""}
res = requests.post(
url,
headers = headers,
json = data,
verify = False
)
print(res.status_code)
print(res.text)
#####################################
When I run the above, the following will be displayed.
500
[{"ErrorCode":"EPM000001E","ErrorMessage":"Internal Error."}]
12-06-2023 06:56 PM
Hi everyone,
This problem solved! It was the server URL that was the problem.
Incorrect:
url = "https://jp.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
Correct:
url = "https://jp153.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
Actually, there were no other problems other than the above.
To explain, "jp.epm.cyberark.com" is the address of the Dispatcher server, and this API will not work unless it is a server after being dispatched.
11-24-2023 03:23 AM
Hi @Koichiro Ota I see the following three issues in the script.
1.Indentation Issue:Python relies on indentation to define blocks of code. Ensure proper indentation throughout the script.
2.Authorization Header:The “Authorization” header should use the word “Basic” instead of “basic” in the authorization scheme
3.Quotes in the Data Payload:
Ensure consistent use of quotes in the data payload. In the provided script, double and triple double-quotes are used. Stick to one type for consistency.
11-24-2023 04:52 AM
Hi @Koichiro Ota Please check whether the following updated script helps
import requests
import json
token = "<Token that has been researched in advance>"
setID = "<SetID that has been researched in advance>"
url = "https://jp.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
headers = {"Content-Type": "application/json", "Authorization": "Basic " + token}
data = {"filter": 'fileName CONTAINS "notepad++"'}
res = requests.post(
url,
headers=headers,
json=data,
verify=False
)
print(res.status_code)
print(res.text)
11-24-2023 01:18 PM
Hi. If you are happy with the above answer, can you please mark it as ‘Best Answer’ ?
11-24-2023 09:28 PM
Hi @Malhar Vora,
Thank you very much. But it didn't work well.
#####################################
import requests
import json
token = "<Token that have been researched in advance>"
setID = "<SetID that have been researched in advance>"
url = "https://jp.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
headers = {"Content-Type": "application/json", "Authorization": "Basic " + token}
data = {"filter": 'fileName CONTAINS "notepad++"'}
res = requests.post(
url,
headers = headers,
json = data,
verify = False
)
print(res.status_code)
print(res.text)
#####################################
The result of running the above script is below.
500
[{"ErrorCode":"EPM000001E","ErrorMessage":"Internal Error."}]
11-25-2023 01:30 AM
Hi @Koichiro Ota Just wanted to check, are you able to use Postman to test the authentication to EPM API and see if that is successful?
11-25-2023 09:34 PM
Hi @Malhar Vora , Thank you for your reply.
Of course, the authentication is successful. If authentication fails, a message like the one below will be displayed.
401
[{"ErrorCode":"EPM000003E","ErrorMessage":"Your session has expired and your user has been disconnected."}]
By the way, Mr. Malhar, may I ask you a question? Do you have the environment to try these?
11-25-2023 11:46 PM
Hi @Koichiro Ota Sorry I don’t have access to EPM portal to be able to validate it
11-26-2023 04:29 PM
Is that so. Thank you very much.
Is there anyone else besides me who can try it?
11-28-2023 07:11 AM
Hi @Koichiro Ota,
Did you try without filter (fileName CONTAINS \"notepad++\)?
Thanks,
Tamir
11-28-2023 05:06 PM
Hi @Tamir Hochman ,
thank you for the advice.
Actually, I have already tried it and executed the following script.
#####################################
import requests
import json
token = "<Token that have been researched in advance>"
setID = "<SetID that have been researched in advance>"
url = "https://jp.epm.cyberark.com/EPM/API/Sets/" + setID + "/Events/Search"
headers = {"Content-Type": "application/json", "Authorization": "Basic " + token}
res = requests.post(
url,
headers = headers,
verify = False
)
print(res.status_code)
print(res.text)
#####################################
The above result is below.
500
[{"ErrorCode":"EPM000001E","ErrorMessage":"Internal Error."}]
12-03-2023 05:51 AM
Hi @Koichiro Ota,
I can share that we tested it internally, and everything worked as expected.
To assist, we will need to see a recording of how exactly you perform the login and query the problematic API.
Can you please open a support case so we can analyze the logs and understand the root cause?
Link: https://community.cyberark.com/s/Submit-a-Case
Thanks,
Tamir
12-03-2023 05:03 PM
Hi @Tamir Hochman ,
Thank you very much. I tried to open a support case, but the screen below keeps showing up. Even if I press the continue button, there is no response.
12-03-2023 10:23 PM
Hi @Koichiro Ota,
Following on the script. You should try with PostMan and verify the functionality.
If it works you need to debug the script as the service is working as expected.
Regarding the support ticket:
To raise a support ticket, users who should have access to support tickets will navigate to the main page of the Technical Community > Click on the 'Requests' Tab > "Cases" > "New Case" button (located on the right side of the screen).
Using direct links to the community is not recommended, as URLs may often change and become outdated (as in your case, as you've listed an old unused URL).
If you don't have access to raise or review support tickets. Please contact [email protected] or your CyberArk representative for further assistance if you require such access.
In the meantime, if you need additional assistance or would like to explore other support options, please visit the CyberArk official website at: https://www.cyberark.com/services-support/technical-support-contact/
I hope your issue will be resolved soon!
Thanks,
Tamir
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

