How to construct JSON codes to insert or update the contact Status property?

SOLVE
Benchmark_achen
Participant

Hi All,

I'm new to Hubspot.  I'm trying to POST some contact records from our database into Hubspot using Hubspot API.  It works with the basic property such as the contact last name, first name, email, phone, address, etc.  However, when I added the status property, it failed with the following message:

 

"Response Body: {"validationResults":[{"isValid":false,"message":"1 was not one of the allowed options: [label: \"Active\"\nvalue: \"active\"\nread_only: true\n, label: \"Inactive\"\nvalue: \"inactive\"\nread_only: true\n]","error":"INVALID_OPTION","name":"hs_content_membership_status"}],"status":"error","message":"Property values were not valid","correlationId":"5ae5251d-f999-485a-b9c8-a5f92007c4e5","requestId":"32dfc68887aaf82880cb58ec7f2980ee"}"

 

Here is the sample JSON record:

{
"properties": [
{
"property": "FirstName",
"value": "ABC"
},
{
"property": "LastName",
"value": "XYZ"
},
{
"property": "Email",
"value": "ABCXYZ@gmail.com"
},
{
"property": "Address",
"value": "54 Peirce Rd"
},
{
"property": "City",
"value": "Waltham"
},
{
"property": "State",
"value": "MA"
},
{
"property": "zip",
"value": "02420"
},
{
"property": "hs_content_membership_status",
"value": "1"
}
]
}

 

Here is the API that I use:

https://api.hubapi.com/contacts/v1/contact

 

Can someone tell me how to properly code the status property for posting?

 

Thanks,

Allan

0 Upvotes
2 Accepted solutions

Accepted Solutions
himanshurauthan
Solution
Recognized Expert | Platinum Partner
Hello there,

You need to send the data as -

{
"property" : "hs_content_membership_status",
"value" : "active"
}

And same pattern when you have to mark inactive status, just change the value to inactive.

I hope this helps.

Thanks
Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

Benchmark_achen
Solution
Participant

That works! Smiley Happy

 

Thank you very much!

--Allan

View solution in original post

4 Replies 4
himanshurauthan
Recognized Expert | Platinum Partner
Hello there,

Everything is fine with your request. Just need to update the value that you are sending under status property. On hubspot for this property we have two options available and they are active or inactive. So in order to match drop-down select property value, we need a value from those options. Please try to send active for value 1 and inactive for value 0.

Thanks
Digital Marketing & Inbound Expert In Growth Hacking Technology
0 Upvotes
Benchmark_achen
Participant

I updated the JSON script for the status property with these codes:

 

{
"property": "hs_content_membership_status",
"active": "1",
"inactive": "0"
}

 

I was able post this record to Hubspot without error.  However, if I look at the Status property in the Hubspot app, the Status value is blank (I'm expecting it to indicate "Active").  I can manually change it to Active by select it from the dropdown and save, but that's not what I want to do.

 

Any suggestions?

 

Thanks,

Allan

0 Upvotes
himanshurauthan
Solution
Recognized Expert | Platinum Partner
Hello there,

You need to send the data as -

{
"property" : "hs_content_membership_status",
"value" : "active"
}

And same pattern when you have to mark inactive status, just change the value to inactive.

I hope this helps.

Thanks
Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

Benchmark_achen
Solution
Participant

That works! Smiley Happy

 

Thank you very much!

--Allan

View solution in original post