I have the issue in the SugarCRM REST Function. I have created the Sugar Module I am working in that. I have dashlet file for a REST call and in that, there is the function, So from that function whatever I return, That response always truncates the last 2 characters.
Initially I was thinking this is the issue from REST API, but for now I hardcoded the response but still, the issues are there.
Suppose I return "Hello World", Then I am getting the response "Hello Wor"
<?php require_once('include/api/SugarApi.php');require_once 'include/SugarTheme/SidecarTheme.php';require_once('custom/clients/base/helper/SecurityHelper.php');class FreshDashletApi extends SugarApi{ public function registerApiRest() { return array( 'freshdeskdashlet' => array( 'reqType' => 'GET', 'path' => array('freshdeskdashlet'), 'pathVars' => array(''), 'method' => 'getFreshdeskDashlet', 'shortHelp' => '', 'longHelp' => '', ), 'ticketfields' => array( 'reqType' => 'GET', 'path' => array('ticketfields'), 'pathVars' => array(''), 'method' => 'getCustomFields', 'shortHelp' => '', 'longHelp' => '', ), ); } public function getFreshdeskDashlet($api, $args) { $data = array ( 'ticket_json' => array ( 0 => array ( 'associates_rdb' => NULL, 'association_type' => NULL, 'cc_email' => array ( 'cc_emails' => array ( ), 'fwd_emails' => array ( ), 'reply_cc' => array ( ), 'tkt_cc' => array ( ), ), 'created_at' => '2019-02-05T15:06:30+05:30', 'deleted' => false, 'delta' => true, 'description' => 'This is our test ticket for Sugar CRM Test', 'description_html' => ' This is our test ticket for Sugar CRM Test ', 'dirty' => 0, 'display_id' => 22, 'due_by' => '2019-02-08T15:06:30+05:30', 'email_config_id' => NULL, 'frDueBy' => '2019-02-06T15:06:30+05:30', 'fr_escalated' => false, 'group_id' => NULL, 'id' => 42017573142, 'internal_agent_id' => NULL, 'internal_group_id' => NULL, 'isescalated' => false, 'owner_id' => NULL, 'parent_ticket_id' => NULL, 'priority' => 1, 'requester_id' => 42008575970, 'responder_id' => NULL, 'sl_escalation_level' => NULL, 'sl_manual_dueby' => NULL, 'sl_merge_parent_ticket' => NULL, 'sl_product_id' => NULL, 'sl_skill_id' => NULL, 'sl_sla_policy_id' => NULL, 'sla_state' => 0, 'source' => 3, 'spam' => false, 'st_survey_rating' => NULL, 'status' => 2, 'subject' => 'Sugar Test', 'ticket_type' => 'Question', 'to_email' => NULL, 'trained' => false, 'updated_at' => '2019-02-05T15:06:30+05:30', 'urgent' => false, 'status_name' => 'Open', 'requester_status_name' => 'Being Processed', 'priority_name' => 'Low', 'source_name' => 'Phone', 'requester_name' => 'Amol Rokade', 'responder_name' => 'No Agent', 'to_emails' => NULL, 'product_id' => NULL, 'custom_field' => array ( ), ), ), 'domain' => 'abc.pqr.com', 'credentials' => 'X2Y9CfvfdvseUUZvdfvfdvvfvf7e3Pud1tI', 'ssl' => 'http', 'ticket_fields' => array ( 'ticket_fields' => array ( 'ticket_type' => array ( 'Question' => 'Question', 'Incident' => 'Incident', 'Problem' => 'Problem', 'Feature Request' => 'Feature Request', ), 'ticket_status' => array ( 'Open' => 2, 'Pending' => 3, 'Resolved' => 4, 'Closed' => 5, 'Waiting on Customer' => 6, 'Waiting on Third Party' => 7, ), 'ticket_priority' => array ( 'Low' => 1, 'Medium' => 2, 'High' => 3, 'Urgent' => 4, ), 'ticket_group' => array ( 'Product Management' => 42000076370, 'QA' => 42000076371, 'Sales' => 42000076372, ), 'agent' => array ( 'John Deo' => 42001642325, ), ), ), 'email' => 'John@gmail.co.in', 'tickets' => array ( 0 => array ( 'ticket_field' => array ( 'active' => true, 'column_name' => NULL, 'created_at' => '2018-05-02T10:07:06+05:30', 'default' => true, 'description' => 'Ticket status', 'editable_in_portal' => false, 'field_options' => NULL, 'field_type' => 'default_status', 'flexifield_coltype' => NULL, 'flexifield_def_entry_id' => NULL, 'id' => 42000265137, 'import_id' => NULL, 'label' => 'Status', 'label_in_portal' => 'Status', 'level' => NULL, 'name' => 'status', 'parent_id' => NULL, 'position' => 4, 'prefered_ff_col' => NULL, 'required' => true, 'required_for_closure' => false, 'required_in_portal' => false, 'ticket_form_id' => 42000023745, 'updated_at' => '2018-05-02T10:07:06+05:30', 'visible_in_portal' => true, 'choices' => array ( 0 => 'Open', 1 => 'Pending', 2 => 'Resolved', 3 => 'Closed', 4 => 'Waiting on Customer', 5 => 'Waiting on Third Party', ), 'nested_ticket_fields' => array ( ), ), ), ), 'module' => 'Contact', ); return $data; }}
In The console, I am getting below error.
HttpError {request: HttpRequest, status: 200, responseText: "↵↵{"ticket_json":[{"associates_rdb":null,"associat…"],"nested_ticket_fields":[]}}],"module":"Contact", textStatus: "parsererror", errorThrown:
But unfortunately, I unable to find them from where it's exactly doing the JSON Parse and why only last 2 characters are get Truncated.
Any Help will be much appreciated.