Understanding Action's Reponse Format Choices

There are three choices result transformation of data from action results:

  • JSON success result
  • JSONP success result
  • CSV success result (limited to Action ‘find’)
  • JSON error

matapi-action-format-choices

JSON Transformation

Transform output to JSON format.

Example:

/controller_path/action_name.json?param_name=value&param_name=value
{
    "status_pre":200
    "response_size":"119858"
    "data":
        {
        "fields":{}
        "related_entities":
            {}
            "mod_name":"Records\Model\Advertisers"
            "mod_namespace":"Records\Model"
            "mod_shortname":"Advertisers"
        }
}

JSONP Transformation

Transform output to JSON with padding format. JSONP format requires the name of the callback function as a named query parameter value.
Example:

/controller_path/action_name.jsonp?callback=jQuery0123456789&param_name=value&param_name=value
jQuery0123456789(
    {
        "status_pre":200
        "response_size":"12345"
        "data":
        {…}
    }
)

CSV Transformation

The result of this transformation is a downloadable CSV file, and it is available only to a limit set of actions. It also requires providing an array of

fields

, and will not default all available fields for that action’s endpoint.

Example:

/controller_path/action_name.csv?fields=id%2Cname%2Cemail&param_name=value&param_name=value

JSON Transformation for Error Result

If upon calling a controller it is provided with any of the following conditions, then the output will be also in JSON as shown below:

  • Invalid action name
  • Valid action provided with invalid parameters
  • Valid action provided with parameters containing invalid data

Example: /v2/controller_path/action_name.json?invalid_parameters

{
        "status_pre":401
        "response_size":"266"
        "data":
            "errors":[
            {
                "message":"API key is missing or invalid."
            ]
        }
    }
Have a Question? Please contact support@tune.com for technical support.