APIs & Integrations

HDhillon
Member

Invalid input JSON on line 1, column 143: Cannot deserialize value of type `java.lang.String` from O

SOLVE

getting an error while creating a contact or deal with this code 

const hubspot = require('@hubspot/api-client');

const hubspotClient = new hubspot.Client({"accessToken":"NOPE"});

const properties = {
"properties": {
"amount": "1500.00",
"closedate": "2019-12-07T16:50:06.678Z",
"dealname": "New deal",
"pipeline": "default",
"dealstage": "contractsent",
"hubspot_owner_id": "910901"
}
};
const SimplePublicObjectInputForCreate = { associations: [{"types":[{"associationCategory":"HUBSPOT_DEFINED","associationTypeId":0}],"to":{"id":"string"}}], properties };

try {
const apiResponse = await hubspotClient.crm.deals.basicApi.create(SimplePublicObjectInputForCreate);
console.log(JSON.stringify(apiResponse, null, 2));
} catch (e) {
e.message === 'HTTP request failed'
? console.error(JSON.stringify(e.response, null, 2))
: console.error(e)
}- 

this is the error - Invalid input JSON on line 1, column 143: Cannot deserialize value of type `java.lang.String` from Object value (token `JsonToken.START_OBJECT`)

0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Invalid input JSON on line 1, column 143: Cannot deserialize value of type `java.lang.String` from O

SOLVE

Hey, @HDhillon 👋 Thanks for your question. It looks like you've mixed the structure of a public SimplePublicObjectInput class with the actual JSON payload needed by the API.

 

Have you tried something like this?

 

const SimplePublicObjectInputForCreate = {
  associations: {
    dealToContact: ["contact-id"],
    dealToCompany: ["company-id"]
  },
  properties
};

 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

View solution in original post

0 Upvotes
2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Invalid input JSON on line 1, column 143: Cannot deserialize value of type `java.lang.String` from O

SOLVE

Hey, @HDhillon 👋 Thanks for your question. It looks like you've mixed the structure of a public SimplePublicObjectInput class with the actual JSON payload needed by the API.

 

Have you tried something like this?

 

const SimplePublicObjectInputForCreate = {
  associations: {
    dealToContact: ["contact-id"],
    dealToCompany: ["company-id"]
  },
  properties
};

 

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Invalid input JSON on line 1, column 143: Cannot deserialize value of type `java.lang.String` from O

SOLVE

I removed your access token from the post, but you should probably rotate it just to be safe. — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes