Get The Most Affordable Hosting in the World!

Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.

Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!

Get Started Now!

During the development process, you may need to verify whether your API code is working correctly. You can use several methods to do this.

You can find comprehensive API reference guides with use examples in our Developer Documentation.

API Sample Code

You can verify your code using the sample code in our documentation. This will allow you to check whether it can run without any modifications.

Example Request (Local API)

$command = 'GetUsers';
$postData = array(
    'search' => 'username@example.net',
    'responsetype' => 'json',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional

$results = localAPI($command, $postData, $adminUsername);
print_r($results);
 

Example Response JSON

{
    "result": "success",
    "totalresults": 1,
    "startnumber": 0,
    "numreturned": 1,
    "users": [
        {
            "id": 1,
            "firstname": "John",
            "lastname": "Smith",
            "email": "john.smith@example.net",
            "datecreated": "2020-12-15 15:29:49",
            "validationdata": "",
            "clients": [
                {
                    "id": 1,
                    "isOwner": true
                }
            ]
        }
    ]
}
 

If the sample code succeeds but your custom code does not, the issue is likely within your own custom code.

If the sample code does not run, the issue may require general troubleshooting.

You can also use the API code samples to begin your custom code and then verify your changes after each modification. If the results begin to include errors, you can easily identify the problems.

API Logging (Advanced)

If you want to debug API calls at a transactional level, you can enable API debugging in the configuration.php file by adding the following line:

$api_enable_logging = true;
 

This will log the data in the tblapilog table in your WHMCS database.

For WHMCS v7.2 and earlier, create an apilog.txt file in the includes directory and set the permissions to 777  to ensure that the log file works.

After you finish troubleshooting, you must remove the line from your configuration.php file and delete the log file.

 
 
The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.
Was this answer helpful? 1 Users Found This Useful (1 Votes)

Powered by WHMCompleteSolution