AnsweredAssumed Answered

How to get json data in REST endpoint

Question asked by Andrew Gin on Dec 7, 2016
Latest reply on Dec 7, 2016 by Andrew Gin

I have added an extra action to the recordlist view;


    extendsFrom: 'RecordlistView',
    initialize: function(options) {
        this._super("initialize", [options]);
        //add listener for custom button
        this.context.on('list:export2:fire', this.export2, this);
    export2: function() {
        var selected = this.context.get("mass_collection").pluck('id');
        if (selected) {
                success: function(response) {
                error: function(response) {
                complete: function(response){
                error: function(response){

The tutorial here Explains how to create an endpoint.

However it doesn't explain how to get the json data (the stringified array of selected ids);


if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class OpportunitiesApi extends SugarApi
    public function registerApiRest()
        return array(
            'MyGetEndpoint' => array(
                //request type
                'reqType' => 'GET',

                //set authentication
                'noLoginRequired' => false,

                //endpoint path
                'path' => array('Opportunities', 'Export2'),

                //endpoint variables
                'pathVars' => array('', ''),

                //method to call
                'method' => 'Export2',

                //short help string to be displayed in the help documentation
                'shortHelp' => 'Export',

                //long help to be displayed in the help documentation
                'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',

     * Method to be used for my MyEndpoint/GetExample endpoint
    public function Export2($api, $args)
        //how to access $args['selected_ids']?



$args contains

    [__sugar_url] => v10/Opportunities/Export2

Is it possible to access the json data?