# PHP API Exceptions Truncated

**URL:** <https://community.hubspot.com/t/php-api-exceptions-truncated/64079>\
**Category:** APIs & Integrations\
**Tags:** php\
**Created:** [August 30, 2022, 5:24pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079 "2022-08-30T17:24:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![EHowey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ehowey/32/196242_2.png) [@EHowey](https://community.hubspot.com/u/EHowey)\
**Post date:** [August 30, 2022, 5:24pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/1 "2022-08-30T17:24:23Z")

</div>

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

```lia-code-sample
[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?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 31, 2022, 8:35pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/2 "2022-08-31T20:35:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danhammari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danhammari/32/11850_2.png) [@danhammari](https://community.hubspot.com/u/danhammari)\
**Post date:** [September 1, 2022, 4:06pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/3 "2022-09-01T16:06:31Z")

</div>

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:

> <https://stackoverflow.com/questions/19748105/handle-guzzle-exception-and-get-http-body>

Here is something I have used with the hubspot api:

```lia-code-sample
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();
}

```

---

<div class="post-metadata">

**Author:** ![EHowey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ehowey/32/196242_2.png) [@EHowey](https://community.hubspot.com/u/EHowey)\
**Post date:** [September 1, 2022, 5:39pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/4 "2022-09-01T17:39:51Z")

</div>

Beautiful. Thank you!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 1, 2022, 5:46pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/5 "2022-09-01T17:46:52Z")

</div>

Thank you very much @danhammari and @Nickm66 🙌

---

<div class="post-metadata">

**Author:** ![Nickm66](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nickm66/32/74736_2.png) [@Nickm66](https://community.hubspot.com/u/Nickm66)\
**Post date:** [September 1, 2022, 1:07pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/6 "2022-09-01T13:07:45Z")

</div>

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

> **[log\_errors\_max\_len - PHP: Runtime Configuration - Manual](https://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors-max-len)**
>
> The behaviour of these functions is affected by settings in php.ini. | Runtime Configuration

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?

---

<div class="post-metadata">

**Author:** ![Nickm66](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nickm66/32/74736_2.png) [@Nickm66](https://community.hubspot.com/u/Nickm66)\
**Post date:** [September 1, 2022, 2:20pm UTC](https://community.hubspot.com/t/php-api-exceptions-truncated/64079/7 "2022-09-01T14:20:06Z")

</div>

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:

> **[Guzzle Error Message gets truncated](https://laracasts.com/discuss/channels/general-discussion/guzzle-error-message-gets-truncated)**
>
> Good evening,
> sometimes I get an error message while calling on an API using Guzzle.
> What drives me crraaaaaazzzyyy is the fact that the important part of the error message gets truncated! For Example:
> exception 'GuzzleHttp\\Exception\\ClientException'...

> **[Solving: Guzzle errors truncated](https://dcblog.dev/solving-guzzle-errors-truncated)**
>
> I'm a big fan of Guzzle it's great for making API calls. But when there is an error retur...
