Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

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?



  • No labels