Hello,
I am trying to leverage the Atlassian API/Python to dump all audit log events from yesterday to a json file. Here is what I am trying:
import requests
import json
from datetime import datetime, timedelta
yesterday = datetime.now() - timedelta(days=1)
yesterday_str = yesterday.strftime("%Y-%m-%d")
url = "https://api.atlassian.com/admin/v1/orgs/<org id>/events"
headers = {
"Accept": "application/json",
"Authorization": "Bearer <api key>"
}
query_params = {
"from": yesterday_str,
"to": yesterday_str
}
response = requests.request(
"GET",
url,
headers=headers,
params=query_params
)
events = json.loads(response. Text)
with open('yesterday_events.json', 'w') as f:
json.dump(events, f, sort_keys=True, indent=4, separators=(",", ": "))
I get the following error:
{
"detail": "Invalid date: 2023-04-19",
"error": "Internal Server Error",
"id": "d03b2feb-4a34-4418-a189-994d32b64ecb",
"path": "/v2/client/access/container/<ORG ID REMOVED>/events",
"requestId": "8373c32b-1077441",
"status": 400,
"timestamp": "2023-04-20T16:33:30.222+00:00",
"title": "IllegalArgumentException"
}
Thanks!
Garry