APIs & Integrations

NSaad
Member

Error: Cannot Deserialize

SOLVE

I'd like to know why the following request fails with this error. It's not clear as to what's going on, as it matches the expected format.

 

Error:

`{"status":"error","message":"Invalid input JSON on line 1, column 17: Cannot deserialize value of type `java.util.ArrayList<com.hubspot.crmpublic.core.models.associations.PublicAssociationsForObject>` from Object value (token `JsonToken.START_OBJECT`)","correlationId":"REDACTED"}`

 

Request Sent (Sent as one line, but multiline here for ease of viewing):

```

{
"inputs": [
{
"idProperty": "email",
"id": "aaa@aaa.com",
"properties": {
"email": "aaa@aaa.com",
"firstname": "Aaa",
"lastname": "Bbb",
"address": "123 Main St",
"city": "Edmonton",
"state": "AB ",
"zip": "T6W2R6",
"phone": "+11231231234"
}
}
]
}

```

This page shows the following sample format: https://developers.hubspot.com/beta-docs/guides/api/crm/objects/contacts#upsert-contacts

 

```

// Example request body with email
// POST /crm/v3/objects/contacts/batch/upsert
{
"inputs": [
{
"properties": {
"phone": "5555555555"
},
"id": "test@test.com",
"idProperty": "email"
},
{
"properties": {
"phone": "7777777777"
},
"id": "example@hubspot.com",
"idProperty": "email"
}
]
}

```

 

Please note that I have tried truncating the properties to just send the email. So, it's not that. Any help is greatly appreciated.

0 Upvotes
1 Accepted solution
GiantFocal
Solution
Top Contributor | Partner
Top Contributor | Partner

Error: Cannot Deserialize

SOLVE

Hi @NSaad,

 

You'll need to ensure your request follows the exact format from the HubSpot API documentation:

 

{
  "inputs": [
    {
      "properties": {
        "phone": "5555555555"
      },
      "id": "test@test.com",
      "idProperty": "email"
    }
  ]
}

 

The order of properties in the request matters. You should put properties first, followed by id and idProperty. Also, remember to remove any extra whitespace or formatting.

Best regards,
Ernesto @ GiantFocal
Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!

View solution in original post

1 Reply 1
GiantFocal
Solution
Top Contributor | Partner
Top Contributor | Partner

Error: Cannot Deserialize

SOLVE

Hi @NSaad,

 

You'll need to ensure your request follows the exact format from the HubSpot API documentation:

 

{
  "inputs": [
    {
      "properties": {
        "phone": "5555555555"
      },
      "id": "test@test.com",
      "idProperty": "email"
    }
  ]
}

 

The order of properties in the request matters. You should put properties first, followed by id and idProperty. Also, remember to remove any extra whitespace or formatting.

Best regards,
Ernesto @ GiantFocal
Found this answer helpful?
Marking it as the solution helps both the community and me - thanks in advance!