I know I am using an old version of the PHP API, but I cannot afford the time at the moment or errors it may cause to upgrade to the newer versions.
I have had no issues creating deals in the past, using the following code:
$result = $this->_HubSpotIntegrator->deals()->create($properties, $associations);
Where $this->_HubSpotIntegrator is a valid SevenShores\Hubspot\Http\Client class (and other API functions work fine) and $properties is an array setup with each row =>
name =“dealname”
value =“Test”
and $associations is an array with one association: associatedCompanyIds =“#########”.
This code used to work with no issues, and I changed nothing on my end, and now I recieve the following error message:
Invalid input JSON on line 1, column 342: Trailing token (of type END_OBJECT) found after value (bound as `com.hubspot.deals.base.DealView`): not allowed as per `DeserializationFeature.FAIL_ON_TRAILING_TOKENS`
I do not understand how the JSON string is invalid with the HubSpot class generated it and I do not know what I need to change in order to get this working again. Any assistance is appreciatrd.
Hey, @rsantoro47
Thank you for posting your question. I’d like to invite some of our community members with PHP expertise to the conversation — hey @Teun @stefen @skimura @zach_threadint do you have any suggestions or troubleshooting steps you can recommend to @rsantoro47?
Thank you! — Jaycee
Thank you, any help is greatly appreciated.
I found a workaround for this. It appears that the issue was that I was sending associations along with the create.
If you look at the PHP Classes to create a deal, there is an optional parameter for associations:
public function create(array $properties, array $associations = [])
And the documention indicates (Accounts Dashboard | HubSpot
Example request JSON:
{
“associations”: {
“associatedCompanyIds”: [
8954037
],
“associatedVids”: [
27136
]
},
“properties”: [
{
“value”: “Tim’s Newer Deal”,
“name”: “dealname”
},…
I realzie this is the v1.0 API but all of my code has been built around this and it has been working. It is on our product roadmap to update, but it is a big project.
I had formatted the associations array exactly as the above JSON requires, and suddently I started recieving the error message I posted above. This used to work, and no longer does. This leads me to beleive something changed on the Hubspot side, but I could find no documentation.
To get around this, I simply removed the association from the create, then used the seperate classes to create the association after the deal was created. If Hubspot could either fix this on their end, or update the documentation, that would be helpful.