API Error on Transactional Single Sends

Using PHP, we’re attempting to do a transactional email “simple send” fails, despite building my Request object using the RequestEgg.

Full error:

{"status":"error","message":"Invalid input JSON on line 1, column 67: Cannot deserialize value of type java.util.LinkedHashMap<java.lang.String,java.lang.String>from Array value (tokenJsonToken.START_ARRAY)","correlationId":"7ab5cf67-6968-476a-8b66-2e0a76c9cf9d"}

Here’s the section of code throwing the error:

$email = new \HubSpot\Client\Marketing\Transactional\Model\PublicSingleSendRequestEgg([
 'email_id' => 123456789,
 'message' => [
 'to' => 'myemail@email.com',
 ],
 'contact_properties' => [
 [
 'name' => 'firstname',
 'value' => 'MyName'
 ]
 ],
 'custom_properties' => [
 [
 'name' => 'trackingNumber',
 'value' => '12345678987654321'
 ]
 ]
]);
return $HubSpot->marketing()->transactional()->singleSendApi()->sendEmail($email);

Curious if anyone can help point us in the right direction?

@craigcri

Hi.

`PublicSingleSendRequestEgg` parameter might be wrong.

How about check `hubspot API reference` ? It’s very useful.

It has sample code(include PHP) and test tool.

Thanks.

That’s what I thought as well, but I’ve validated RequestEgg and it has returned valid.

Even trying to push an Object or Json string into it, it expects value as an Array, so I feel it is formatted correctly.

Even using Setter methods for the required parameters, passing it to the Send function throws the same error.

Turns out my formatting was incorrect for custom properties and contact properties above. Items are no longer formatted in individual arrays.

Also I discovered even if your Contact Properties or Custom Properties are empty arrays, it will throw errors. Sad.