APIs & Integrations

Adithya868495
Member

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hi,

I have been receiving corrupted error message when I try to create a contact using this endpoint -> POST - contacts/v1/contact. I am working on handling error scenario in our integration, so I know the cause of the error. but the error response message that I received seems to be corrupted. I am unable to read thorugh the error message due to this issue.

Example 

{ 
    properties:  {
      firstname: 'Trial_01',   
      hs_lead_status: '99656+6666',
      email: 'this@example.com',
      range: '50',
      number_input: '555',
      drop_down: 'Option 3',
      phone: '9888',
}

So this is an example error case scenario where i know the hs_lead_status cannot be set to '99656+6666' because it has fixed set of values. 

Error Message Response I got - 

Property values were not valid: [{"isValid":false,"message":"99656+6666 was not one of the allowed options: [label: \"New\"\nvalue: \"NEW\"\ndisplay_order: 0\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Open\"\nvalue: \"OPEN\"\ndisplay_order: 1\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"In Progress\"\nvalue: \"IN_PROGRESS\"\ndisplay_order: 2\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Open Deal\"\nvalue: \"OPEN_DEAL\"\ndisplay_order: 2\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Unqualified\"\nvalue: \"UNQUALIFIED\"\ndisplay_order: 3\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Attempted to Contact\"\nvalue: \"ATTEMPTED_TO_CONTACT\"\ndisplay_order: 4\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Connected\"\nvalue: \"CONNECTED\"\ndisplay_order: 5\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Bad Timing\"\nvalue: \"BAD_TIMING\"\ndisplay_order: 6\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n]","error":"INVALID_OPTION","name":"hs_lead_status"}]

Since its is corrupted, I am  unable to get data out of it. Any help would be great. 
Thanks

0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @Adithya868495,

 

Thanks for elaborating your use case further. 

 

In this case, while it is currently not possible to easily parse the error message as JSON format, I do have a workaround that I'd love to share with you:

 

You may want to use the Get a contact property endpoint to retrieve the property details. i.e. GET properties/v1/contacts/properties/named/hs_lead_status

 

The return response will show the property options in an array json:

options:[
{
label:"New",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:0,
value:"NEW"},
{
label:"Open",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:1,
value:"OPEN"},
{
label:"In Progress",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:2,
value:"IN_PROGRESS"},
{
label:"Open Deal",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:2,
value:"OPEN_DEAL"},
{
label:"Unqualified",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:3,
value:"UNQUALIFIED"},
{
label:"Attempted to Contact",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:4,
value:"ATTEMPTED_TO_CONTACT"},
{
label:"Connected",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:5,
value:"CONNECTED"},
{
label:"Bad Timing",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:6,
value:"BAD_TIMING"}],

View solution in original post

0 Upvotes
6 Replies 6
WendyGoh
HubSpot Employee
HubSpot Employee

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @Adithya868495,

 

Do you mind clarifying what do you mean by the error mesage is corrupted? 

 

I believe what the error message is trying to indicate is that the creation of contact failed because the value set for property 

hs_lead_status

wasn't one of the allowed options:

1. NEW

2. OPEN

3. IN_PROGRESS

4. OPEN_DEAL

5. UNQUALIFIED

6. ATTEMPTED_TO_CONTACT

7. CONNECTED

8. BAD_TIMING

 

 

0 Upvotes
Adithya868495
Member

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @WendyGoh,

Hope you are doing great.

Corrupted in the sense. I am unable to parse the error message I received. 

Property values were not valid: [{"isValid":false,"message":"S was not one of the allowed options: [label: \"New\"\nvalue: \"NEW\"\ndisplay_order: 0\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Open\"\nvalue: \"OPEN\"\ndisplay_order: 1\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"In Progress\"\nvalue: \"IN_PROGRESS\"\ndisplay_order: 2\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Open Deal\"\nvalue: \"OPEN_DEAL\"\ndisplay_order: 2\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Unqualified\"\nvalue: \"UNQUALIFIED\"\ndisplay_order: 3\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Attempted to Contact\"\nvalue: \"ATTEMPTED_TO_CONTACT\"\ndisplay_order: 4\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Connected\"\nvalue: \"CONNECTED\"\ndisplay_order: 5\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n, label: \"Bad Timing\"\nvalue: \"BAD_TIMING\"\ndisplay_order: 6\ndouble_data: 0.0\nhidden: false\ndescription: \"\"\nread_only: false\n]","error":"INVALID_OPTION","name":"hs_lead_status"}]

 This is the string data which is avaliable in message property. I am unable to convert this String to JSON due to backslashes and newline (ie \ and \n). I tried using regex. but I am unable to change this to JSON. Any help regarding this issue would be great.

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @Adithya868495,

 

Thanks for clarifying. 

 

In this case, you may have to unescape the string first. E.g. of an online tool I used: Free Online JavaScript (JS) Escape / Unescape Tool - FreeFormatter.com in which after unescaping, it'll be like this:

 

Property values were not valid: [{"isValid":false,"message":"99656+6666 was not one of the allowed options: [label: "New"
value: "NEW"
display_order: 0
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Open"
value: "OPEN"
display_order: 1
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "In Progress"
value: "IN_PROGRESS"
display_order: 2
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Open Deal"
value: "OPEN_DEAL"
display_order: 2
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Unqualified"
value: "UNQUALIFIED"
display_order: 3
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Attempted to Contact"
value: "ATTEMPTED_TO_CONTACT"
display_order: 4
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Connected"
value: "CONNECTED"
display_order: 5
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Bad Timing"
value: "BAD_TIMING"
display_order: 6
double_data: 0.0
hidden: false
description: ""
read_only: false
]","error":"INVALID_OPTION","name":"hs_lead_status"}]

without the backlash.

0 Upvotes
Adithya868495
Member

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @WendyGoh 

I understood that I had to escape the String. But my problem is the message property. Please check the message property inside the  Property values were not valid Array. You can find that the message property itself is a String which cannot be converted to JSON. 

I tried regex and string manipulation to convert it to JSON only to understand that they cannot be converted to JSON. 

Property values were not valid: [{"isValid":false,"message":"99656+6666 was not one of the allowed options: [label: "New"
value: "NEW"
display_order: 0
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Open"
value: "OPEN"
display_order: 1
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "In Progress"
value: "IN_PROGRESS"
display_order: 2
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Open Deal"
value: "OPEN_DEAL"
display_order: 2
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Unqualified"
value: "UNQUALIFIED"
display_order: 3
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Attempted to Contact"
value: "ATTEMPTED_TO_CONTACT"
display_order: 4
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Connected"
value: "CONNECTED"
display_order: 5
double_data: 0.0
hidden: false
description: ""
read_only: false
, label: "Bad Timing"
value: "BAD_TIMING"
display_order: 6
double_data: 0.0
hidden: false
description: ""
read_only: false
]","error":"INVALID_OPTION","name":"hs_lead_status"}]



You can try validating the json in this https://jsonformatter.curiousconcept.com/
site or any other json validation tool which is available online. It will so a lot of errors. Just paste the above result and check.  The thing is it will be easier programmatically if we just receive the data as an json object intead of a string, or it should have easier to parse the message property to json. Here both is not possible. I hope you can understand what i am trying to convey here.






0 Upvotes
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

Hey @Adithya868495,

 

Thanks for elaborating your use case further. 

 

In this case, while it is currently not possible to easily parse the error message as JSON format, I do have a workaround that I'd love to share with you:

 

You may want to use the Get a contact property endpoint to retrieve the property details. i.e. GET properties/v1/contacts/properties/named/hs_lead_status

 

The return response will show the property options in an array json:

options:[
{
label:"New",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:0,
value:"NEW"},
{
label:"Open",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:1,
value:"OPEN"},
{
label:"In Progress",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:2,
value:"IN_PROGRESS"},
{
label:"Open Deal",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:2,
value:"OPEN_DEAL"},
{
label:"Unqualified",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:3,
value:"UNQUALIFIED"},
{
label:"Attempted to Contact",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:4,
value:"ATTEMPTED_TO_CONTACT"},
{
label:"Connected",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:5,
value:"CONNECTED"},
{
label:"Bad Timing",
hidden:false,
description:null,
doubleData:null,
readOnly:null,
displayOrder:6,
value:"BAD_TIMING"}],
0 Upvotes
Adithya868495
Member

Create Contact API V1: Receiving Corrupted Error Message

SOLVE

@WendyGoh . Thanks . Seems to solve my issue.

0 Upvotes