Troubleshooting and Debugging WHMCS API Calls: A Comprehensive Guide

thumb_up 1  ·  sell Troubleshooting WHMCS API calls, Debugging issues with API requests and responses, Resolving problems related to API usage in WHMCS.

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?

Related Articles

description

Step-by-Step Guide to Installing WHMCS

To start using WHMCS, you will need to install it on your server. You may need help from your hosting provider or system administrator…

arrow_forward
description

Configuring cPanel Site Software for WHMCS Integration: A How-To Guide

You can install WHMCS using cPanel's Site Software feature. Before you can perform the installation, a WHM user must enable WHMCS…

arrow_forward
description

Effortless WHMCS Installation Using cPanel Site Software: A Step-by-Step Tutorial

You can install WHMCS easily using cPanel's Site Software feature. To do this: 1. If you have not already done so, configure…

arrow_forward
description

Configuring WHMCS Cron Jobs: Step-by-Step Setup Guide

You will need to configure the cron job as soon as you finish installing WHMCS. The cron job executes WHMCS's automation tasks,…

arrow_forward
description

Customizing the WHMCS Cron Schedule: Configuration Guide

The WHMCS cron job performs many of the automated tasks for your WHMCS installation. You can customize when and how often it runs…

arrow_forward
arrow_back « Back