Using the reports API

Jump to solution
wlehnertz
Community Novice

Any admins use the APIs to pull reports?

Background: Trying to automate reports, so we can import certain data into our CRM.

Scripting Language: Python

Report: Zero activity report

I'm trying to automate a few report, but this one is specifically giving me problems right now. I only want a report for the past week. Currently, I receive the All Terms. I pass in the URL parameters below:

params['start_at'] = '2016-05-10T17:00:00Z'
params['enrollment_term_id'] = '13'

I know the term id is correct, as I have pulled it from a previous report I ran. My guess is the date format is wrong, or there's a bug in the API. I pulled the date format from the API docs. I wish the docs included more info about the reports.

Any help would be appreciated.

1 Solution
wlehnertz
Community Novice
Author

Thanks James! You were in the right direction. I made some attempts which failed. I discovered this script and used it as an example. My final parameters dictionary looks like this:

reportParams = {"parameters[start_at]": startDate, "parameters[enrollment_term_id]": enrollment_term_id}

As for the date and time. I used pythons datetime library. We only need a week's worth of data, so I subtracted 7 days from the current date. Below is what that looks like:

startDate = datetime.datetime.now() - datetime.timedelta(days=7)

startDate = str(startDate.isoformat())

View solution in original post