PHP API Exceptions Truncated

When there’s an instance of a property value being invalid, the exception in the PHP API is truncated. See an example below:

[400] Client error: `POST https://api.hubapi.com/crm/v3/objects/contacts?hapikey=<redacted>` resulted in a `400 Bad Request` response:
{"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"Email address 69joeblow@ (truncated...)

How do I get the API to show the full error on exceptions so I can debug what went wrong with the request?

Hi, @EHowey, thanks for reaching out! Let’s see if we can get the conversation started for you.

Hey, @Nickm66 @danhammari @tominal, do you have any PHP wisdom or troubleshooting thoughts for @EHowey

Thank you! — Jaycee

The Guzzle library likes to truncate the error response by default.

You can use its accessors to fetch the full response body, as in this forum discussion:

Here is something I have used with the hubspot api:

try {
 $hubspot_api_response = $hubspot_api_deal_helper->basicApi()->create($new_deal_properties);
 if ($hubspot_api_response) {
 $result['success'] = true;
 $result['hubspot_deal_id'] = $hubspot_api_response->getId();
 }
} catch (\HubSpot\Client\Crm\Deals\ApiException $e) {
 $result['success'] = false;
 $result['messages'][] = $e->getResponseBody();
}

Beautiful. Thank you!

Thank you very much @danhammari and @Nickm66 :raising_hands:

Hi, not seen this before what is the value of this PHP setting?

Maybe increase that?

We’re about to look into the whole hubspot API keys to private apps this week, are you aware of this change?

Ah i think this is actually owing to how guzzle (one of the php packages the API uses).

Similar issue with a different API, hope this helps: