HubSpot / hubspot-api-php

HubSpot API PHP Client Libraries for V3 version of the API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tickets()->associationsApi()->create generates invalid requests

mx-jhinz opened this issue · comments

I am using client version 9.4.0. When creating new associations by using

$client->crm()->tickets()->associationsApi()->create($ticketId, $toObjectType, $toObjectId, $associationType);

the HubSpot API returns a 400 status code with the response body:

{"status":"error","message":"Invalid input JSON on line 1, column 1: Cannot deserialize value of type `java.util.HashSet<com.hubspot.inbounddb.associations.base.AssociationSpec>` from String value (token `JsonToken.VALUE_STRING`)","correlationId":"<id>"}

The requests fails for any object type (contact, companies, custom objects, ...) - for example:
/crm/v4/objects/tickets/:id/associations/contact/:id

It seams like the request body has invalid contents

commented

HI @mx-jhinz .
Could you share your $associationType , please?

Hi @ksvirkou-hubspot ,
the $associationType is one of ticket_to_contact, ticket_to_company or <custom_object_name>_to_ticket.

commented

as I see you have to put array of $association_spec (create($ticket_id, $to_object_type, $to_object_id, $association_spec))
association_type_id (s)
ticket_to_contact => 16
ticket_to_company => 339

Okay, thanks. Now i see the changes between client v8 and v9: the api interface changed from v3 to v4. I was confused, since the official changelog only mentioned changes in the crm()->associations()->v4(), so i haven't checked the function for crm()->tickets()->associationsApi(). It would be nice to have some sort of upgrade guide in the future to make it easier to upgrade without reviewing all changes in the git history.

@ksvirkou-hubspot also it would be nice, if the client throws exceptions if invalid inputs are inserted and Hubspot API Java Util errors responses would be handled correctly.