Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error when using api.ListInvestigations #3

Open
creedsin opened this issue Dec 18, 2023 · 1 comment
Open

getting error when using api.ListInvestigations #3

creedsin opened this issue Dec 18, 2023 · 1 comment

Comments

@creedsin
Copy link

code

"import InsightIDR4Py as idr
from datetime import datetime, timedelta, timezone

define API key (store this value securely)

api_key = "apikey"

connect to InsightIDR API

api = idr.InsightIDR(api_key)

list investigations from the past 7 days

start_time_7d_ago = (datetime.now(timezone.utc) - timedelta(7)).strftime("%Y-%m-%dT%H:%M:%SZ")
print(start_time_7d_ago)

investigations = api.ListInvestigations(start_time=start_time_7d_ago)"

error

"Traceback (most recent call last):
File "C:\Users\user\Desktop\v1.py", line 14, in
investigations = api.ListInvestigations(start_time=start_time_7d_ago)
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\InsightIDR4Py.py", line 240, in ListInvestigations
params["index"] += 100
KeyError: 'index' "

@awtomb
Copy link

awtomb commented Feb 14, 2024

Encountering the same as @creedsin.

PoC Stub:

define API key (store this value securely)

api_key = ""

api = idr.InsightIDR(api_key) start = (datetime.now(timezone.utc) - timedelta(7)).strftime("%Y-%m-%dT%H:%M:%SZ") print(start) investigations = api.ListInvestigations(start_time=start)

Error:

`Cell In[11], line 4
1 start = (datetime.now(timezone.utc) - timedelta(7)).strftime("%Y-%m-%dT%H:%M:%SZ")
2 print(start)
----> 4 investigations = api.ListInvestigations(start_time=start)

File ~/.local/lib/python3.10/site-packages/InsightIDR4Py.py:232, in InsightIDR.ListInvestigations(self, assignee_email, start_time, end_time, multi_customer, priorities, sort, sources, statuses, tags)
230 result = response.json()
231 # get the total
--> 232 total = result["metadata"]["total_data"]
233 # add the results to the output list
234 investigations.extend(result["data"])`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants