Troubleshooting API Errors

Information you need before contacting Support

  1. What language are you using?
  2. Are you using our SDK for that language?  (You should.  The SDKs are excellent.)
  3. Using the information below, what is your error?
    1. Is this an authentication issue?
    2. Are you receiving an error in the logs?  What error?
    3. Are you receiving unexpected results?  What were you expecting and what did you receive?
  4. If we can't help you with the above information, we're going to need to see code.  Pull out the smallest workable code block you can and let us see what you're doing.
    1. Create an issue on GitHub: https://github.com/UltraCart (create the issue in the proper sdk project).
    2. Email your script or a small zip file to support@ultracart.com

Examine the Response

Detailed error messages are returned for most API errors within the response body.    

However, clients such as the PHP SDK raise an exception with a very generic message.

For better troubleshooting, fine tune your try/catch blocks to trap the ApiException.  It yields more information.


Example:

Catching the ApiException
<?php
require_once(__DIR__ . '/SwaggerClient-php/autoload.php');

ultracart\v2\Configuration::getDefaultConfiguration()->setApiKey('x-ultracart-simple-key', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

$api_instance = new ultracart\v2\api\CustomerApi();
$customer_profile_oid = 1234567; // int | The customer oid to retrieve.

try {
    $result = $api_instance->customerCustomersCustomerProfileOidGet($customer_profile_oid);
    print_r($result);
} catch (\ultracart\v2\ApiException $e) {
    echo 'Exception when calling CustomerApi->customerCustomersCustomerProfileOidGet: ', $e->getMessage(), PHP_EOL;
    // THE FOLLOWING LINE PROVIDES DETAILED ERROR INFORMATION
    print_r($e->getResponseObject());
}

Read the Logs

  • View the response and the request.
    1. Are you sure you're sending what you think you're sending?
    2. What does the response say?  Is it an error?  Is it a valid response?  If it is valid, are you consuming it properly?