2

I'm using CiviCRM as a WordPress plugin. I've created a report with a URL like:

https://example.com/wp-admin/admin.php?page=CiviCRM&q=civicrm/report/instance/123

I can visit that page and click the "Export CSV" button. Now, I want to write a script with the Google Sheets API that loads this CSV and updates a Google Sheet. Therefore, I need a direct link to the CSV-formatted report, so my script can issue an HTTP GET and receive the CSV data.

Is there a URL parameter I can pass, or some other way to directly link to the CSV?

  • 1
    Not really an answer but this might be tricky because the export csv button actually runs functions to compile the file and force the download using php header() and content-disposition attachment. See line 224 etc here to look at how it is working: github.com/civicrm/civicrm-core/blob/master/CRM/Report/Utils/…. You could probably write an extension that invokes the functions to generate the csv based on what's going on here. Or perhaps one exists? – Eli Lisseck Feb 27 '17 at 16:20
  • Thanks, that seems like an authoritative "No". If you submit your comment as an answer instead I'll accept it, thank you. – A. Jesse Jiryu Davis Feb 27 '17 at 21:15
1

This might be tricky because the export csv button actually runs functions to compile the file and force the download using php header() and content-disposition attachment. See line 224 etc here to look at how it is working: https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Utils/Report.php.

You could probably write an extension that invokes the functions to generate the csv based on what's going on here. Or perhaps one exists?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.