AnsweredAssumed Answered

Extending API method

Question asked by Nicola Rossato on May 26, 2016
Latest reply on Jun 1, 2016 by Nicola Rossato

Hi all,

I have to extend saveFilePost in clients/base/api/FileApi.php, looking at…  seems so simple. In my case I have put in custom/clients/base/api/CustomFileApi.php this code:


class CustomFileApi extends FileApi {
    public function registerApiRest() {
        return parent::registerApiRest();
    public function saveFilePost($api, $args, $temporary = false) {
        $field = $args['field'];
        $bean = $this->loadBean($api, $args);
        $def = $bean->field_defs[$field];
        if($def['type'] == 'MyNewFileType') {
            $def['type'] = 'image';
        $response = parent::saveFilePost($api, $args, $temporary);
        return $response;


Looking at {my_sugar}/rest/v10/help I've seen there are two identical endpoints, the only difference is the score, one is 9.50 (original) and one is 10.00 (custom).

I was thinking that this number is the priority but placing some breakpoints the call only stop in the original method.

Can someone help me? Thanks in advance.