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

John Mertic —  November 7, 2013 — 5 Comments

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/modules/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


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.

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


    Where can one download all of the other files you reference here?


    Thanks, this is great! But, should the file be saved in “custom/Reports/clients/base/api/” as mentioned above, or is “custom/modules/Reports/clients/base/api/” more appropriate?



    For v10 of the api is it possible to use the module loader with this php script from the dev blog to extend the API to all csv exports of Reports that are already defined via the web interface:


    If so can someone please point me to a resource that spells out the Module Loader functionality a little better?

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