Exporting a report as a CSV using the “new” RESTful API

John Mertic —  November 7, 2013 — Leave a comment

A while back we touched on exporting a report as a PDF using the “new” RESTful API. One thing the reporting tool enables you to do is export ‘Rows and Columns’ reports as CSV files, so naturally being able to do this via the RESTful API would be great as well. But alas, this isn’t possible to do out of the box. But since the API is easily extensible, you can add this in with ease.

To get started, drop the below contents into a new file ReportsExportCsvApi.php in the custom/Reports/clients/base/api/ directory…

Now to get this, just call the endpoint /Reports/<<report id>>/csv, and you’ll get back the CSV formatted file. Note this will only work for ‘Rows and Columns’ reports, as this is the only type where exports work for in the OOTB product.

John Mertic

Posts

John Mertic manages the strategic ISV alliances program for SugarCRM, having several years of techincal experience bringing solutions to market with several SugarCRM technology partners. A frequent conference speaker and an avid writer, he has been published in php|architect, IBM Developerworks, and in the Apple Developer Connection, and is the author of the book 'The Definitive Guide to SugarCRM: Better Business Applications' and the book 'Building on SugarCRM: Creating Applications the Easy Way'. He is also president of the OpenSocial foundation, guiding them in solving interoperability issues for enterprise application providers worldwide.

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s