REST API Specification – Change Language

You can change the language in which the data is returned via API.

To change the API language, you need to pass a parameter with http headers ‘ZURMO_LANG’, and this parameter must contain the language code of a language already installed in the system. If you do not pass this parameter, the response will be returned in the default language.

Below is an example of how to request an account in French:

$authenticationData = login('super','super');
//Add code to check if user is logged successfully

$headers = array(
    'Accept: application/json',
    'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
    'ZURMO_TOKEN: ' . $authenticationData['token'],
    'ZURMO_API_REQUEST_TYPE: REST',
    'ZURMO_LANG: fr',
);

$id = 1; // Change this with value of account id

$response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/accounts/api/read/' . $id, 'GET', $headers);
// Decode json data
$response = json_decode($response, true);
if ($response['status'] == 'SUCCESS')
{
    $account = $response['data'];
    //Do something with account
}
else
{
    // Error, for example if we provided invalid account id
    $errors = $response['errors'];
    // Do something with errors
}

Leave a Comment

  • Alex Teran Caro

    Where this API is located?