- Property to update through API
- How to update property type “multiple checkbox” through API in Node JS ?
Code:
Spoiler
const data = {
“properties”: [
{
“product_lines”:[‘Silver’, ‘Gold’]
}
]};
const updatedDealInfo = await hubspotClient.crm.deals.basicApi.update(dealId, data, idProperty);
console.log(JSON.stringify(updatedDealInfo, null, 2));
--- getting below error when trying to update the property ---
Invalid input JSON on line 1, column 15: Cannot deserialize value of type `java.util.LinkedHashMap<java.lang.String,java.lang.String>` from Array value (token `JsonToken.START_ARRAY`)’
can someone please help on this ?
Hey @malayan,
There are a couple of issues with your code. The first one is that your JSON string is wrapped in brackets - “[ ]” which is causing HubSpot to parse it as an array which it does not expect.
In addition to this when it comes to updating enumeration properties you must include a string separated by a semi-colon. “;”. The code below is an example of how you would update a custom Deal property “Favourite Colour” using the Node Client:
const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ "accessToken": process.env.HUBSPOTTOKEN });
exports.main = async (event) => {
const dealId = event.object.objectId;
const data = {
"properties": {
"favourite_colours": 'Red;Green'
}
};
try {
const apiResponse = await hubspotClient.crm.deals.basicApi.update(dealId, data);
console.log('SUCCESS: ' + JSON.stringify(apiResponse, null, 2));
} catch (e) {
e.message === 'HTTP request failed' ?
console.error('ERROR: ' + JSON.stringify(e.response, null, 2)) : console.error('ERROR: ' + e)
}
}
Resulting in:

I believe updating your code to the below will fix your issues:
const data = {
"properties": {
"product_lines": 'Silver;Gold'
}
};
const updatedDealInfo = await hubspotClient.crm.deals.basicApi.update(dealId, data, idProperty);
console.log(JSON.stringify(updatedDealInfo, null, 2));
Hope this helps! 
Hi @coldrickjack ,
Thanks for the quick response. This was really helpfull.
Instead of lable I used “Internal Value” it worked
const data = {
“properties”: {
“product_lines”: ‘125--Silver;115--Gold’
}
};
Thanks @coldrickjack .