REST V10 Report Data - So Close

Hey Guys,

I've done my research, used wrappers - read the API and all examples end at the same point which is retrieving the report heading\names ect but never the report data.

I've followed the https://developer.sugarcrm.com/?s=Export+Report guide and I get back below.

My expected action is to retrieve the below WITH the report data.

Currently, only the display columns are returned.

I think prehaps before the CURL request I maybe need to POST some stuff to it stating I would like it returned in full... but can't find any documentation or examples on this

My code below

$curl = curl_init($url . "/Reports/c6eaf84e-cde2-38e8-3267-571efc8a4ab7");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json',"OAuth-Token: $token"));
// Make the REST call, returning the result
$response = curl_exec($curl);
//var_dump($response);
$response = json_decode($response);

This outputs the below

stdClass::__set_state(array(
  'team_count' => '',
  'team_name' => 
  array (
  0 => 
  stdClass::__set_state(array(
  'id' => 1,
  'name' => 'Global',
  'name_2' => '',
  'primary' => true,
  )),
  ),
  'id' => 'c6eaf84e-cde2-38e8-3267-571efc8a4ab7',
  'name' => 'Weekly Calendar ',
  'module' => 'Contacts',
  'report_type' => 'tabular',
  'content' => '{"display_columns":[{"name":"date_start","label":"Start Date","table_key":"Contacts:meetings"},{"name":"full_name","label":"Full Name","table_key":"Contacts:assigned_user_link"},{"name":"meeting_type_c","label":"Meeting Type","table_key":"Contacts:meetings"},{"name":"location","label":"Location","table_key":"Contacts:meetings"},{"name":"title","label":"Title","table_key":"self"},{"name":"alt_address_city","label":"Physical Address City","table_key":"self"},{"name":"referral_source_c","label":"Referral Source","table_key":"self"},{"name":"first_appointment_consultant_c","label":"First Appointment Consultant","table_key":"self"},{"name":"first_appointment_c","label":"First Appointment","table_key":"self"},{"name":"booking_fee_c","label":"Booking Fee","table_key":"self"},{"name":"personal_borrow_capacity_c","label":"Personal Borrow Capacity","table_key":"self"},{"name":"smsf_borrowing_capacity_c","label":"SMSF Borrowing Capacity","table_key":"self"},{"name":"status","label":"Status","table_key":"Contacts:meetings"},{"name":"second_meeting_result_c","label":"Meeting Result","table_key":"Contacts:meetings"}],"module":"Contacts","group_defs":[],"summary_columns":[],"report_name":"Weekly Calendar ","chart_type":"none","do_round":1,"numerical_chart_column":"","numerical_chart_column_type":"","assigned_user_id":"975c440f-5951-d8a6-2b2c-54e1764e5324","report_type":"tabular","order_by":[{"name":"date_start","vname":"Start Date","type":"datetimecombo","dbType":"datetime","importable":"required","required":true,"enable_range_search":true,"options":[{"value":"=","text":"Equals"},{"value":"not_equal","text":"Not On"},{"value":"greater_than","text":"After"},{"value":"less_than","text":"Before"},{"value":"last_7_days","text":"Last 7 Days"},{"value":"next_7_days","text":"Next 7 Days"},{"value":"last_30_days","text":"Last 30 Days"},{"value":"next_30_days","text":"Next 30 Days"},{"value":"last_month","text":"Last Month"},{"value":"this_month","text":"This Month"},{"value":"next_month","text":"Next Month"},{"value":"last_year","text":"Last Year"},{"value":"this_year","text":"This Year"},{"value":"next_year","text":"Next Year"},{"value":"between","text":"Is Between"}],"table_key":"Contacts:meetings","sort_dir":"d"}],"full_table_list":{"self":{"value":"Contacts","module":"Contacts","label":"Contacts","dependents":[]},"Contacts:meetings":{"name":"Clients \\u003E Meetings","parent":"self","link_def":{"name":"meetings","relationship_name":"meetings_contacts","bean_is_lhs":false,"link_type":"many","label":"Meetings","module":"Meetings","table_key":"Contacts:meetings"},"dependents":["Filter.1_table_filter_row_1","display_cols_row_1","display_cols_row_3","display_cols_row_4","display_cols_row_14","display_cols_row_15","Filter.1_table_filter_row_1","display_cols_row_1","display_cols_row_3","display_cols_row_4","display_cols_row_14","display_cols_row_15","Filter.1_table_filter_row_1","display_cols_row_1","display_cols_row_3","display_cols_row_4","display_cols_row_13","display_cols_row_14"],"module":"Meetings","label":"Meetings","optional":true},"Contacts:assigned_user_link":{"name":"Clients \\u003E Assigned to User","parent":"self","link_def":{"name":"assigned_user_link","relationship_name":"contacts_assigned_user","bean_is_lhs":false,"link_type":"one","label":"Assigned to User","module":"Users","table_key":"Contacts:assigned_user_link"},"dependents":["display_cols_row_2","display_cols_row_2","display_cols_row_2"],"module":"Users","label":"Assigned to User","optional":true}},"filters_def":{"Filter_1":{"operator":"AND","0":{"name":"date_start","table_key":"Contacts:meetings","qualifier_name":"tp_next_7_days","input_name0":"tp_next_7_days","input_name1":"on"},"1":{"name":"title","table_key":"self","qualifier_name":"not_empty","input_name0":"not_empty","input_name1":"on"}}}}',
  'deleted' => false,
  'date_entered' => '2016-04-26T15:27:17+10:00',
  'date_modified' => '2016-05-03T13:18:47+10:00',
  'assigned_user_id' => '975c440f-5951-d8a6-2b2c-54e1764e5324',
  'modified_user_id' => 'c29ffe9c-c329-4d39-a7b0-54d3b82b58b8',
  'assigned_user_name' => 'CE NSW Calendar',
  'created_by' => '975c440f-5951-d8a6-2b2c-54e1764e5324',
  'is_published' => false,
  'last_run_date' => '',
  'chart_type' => 'none',
  'schedule_type' => 'pro',
  'favorite' => '',
  'my_favorite' => false,
  '_acl' => 
  stdClass::__set_state(array(
  'fields' => 
  stdClass::__set_state(array(
  )),
  )),
  '_module' => 'Reports',
))
Parents
  • The API Endpoint you are using above is simply the <module>/<record_id> API Endpoint and that is why you are returning the Report Record, and not the Report Data.

    You can get the Report Data in PDF format by using the following API Endpoint:

    Reports/<record_id>/pdf

    The only two Export Types included in Sugar by default are PDF and Base64. The developer Article you mentioned above, shows how to add in a CSV export of the data, by adding in a custom Endpoint to the API, and this would be the only way to get a JSON format of the results as well. TO use the Developer article above, your request should go to Reports/<record_id>/csv

    For your scenario you would want to extend the ReportsExportApi (modules/Reports/clients/base/api/ReportsExportApi.php) and add in a 'exportJSON' method to return the JSON formatted results of the report, when accessing Reports/<record_id>/json

     

     

     

  • Hi @Mike Russell, I have followed this steps but I m getting the error while listing the reports. error=> Export type does not exist.

    My Code.

    file name => CustomReportsExportApi.php


    class CustomReportsExportApi extends ReportsExportApi {
     

        public function registerApiRest() {
             return parent::registerApiRest();  
        }

       protected function exportJson(ServiceBase $api, SugarBean $report)
        {

             //my code here

       }

    }

Reply
  • Hi @Mike Russell, I have followed this steps but I m getting the error while listing the reports. error=> Export type does not exist.

    My Code.

    file name => CustomReportsExportApi.php


    class CustomReportsExportApi extends ReportsExportApi {
     

        public function registerApiRest() {
             return parent::registerApiRest();  
        }

       protected function exportJson(ServiceBase $api, SugarBean $report)
        {

             //my code here

       }

    }

Children
No Data