HubSpot Ideas

ke-no

Improve validation error message

Hi team!

 

Validation error of the Contact API is a bit tough to use.

 

When an email in a request is invalid for the Contact API, the error is returned like below format.

 

{
  "status": "error",
  "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"Email address bcooper@gmail.con is invalid\",\"error\":\"INVALID_EMAIL\",\"name\":\"email\"}]",
  "correlationId": "XXX",
  "category": "VALIDATION_ERROR"
}

 

 

As you can see, the details of the errors are contained in the message body, which makes it difficult for applications using the API to parse it.

 

Is it possible to make them structurally separate from the message so that the response can be parsed as JSON and error message is usable as it is.

 

You can reproduce the response by sending below payload to Contact create API

 

{
  "company": "Biglytics",
  "email": "bcooper@gmail.con",
  "firstname": "Bryan",
  "lastname": "Cooper",
  "phone": "(877) 929-0687"
}

 

 

Also, please let us know if there is anything we can do for you at this point, such as changing options in the request.

1 Reply
JW314159
Member

+1, We are experiencing similar issues with the Custom Object API endpoint where we receive generic HTTP-400 responses with category "VALIDATION_ERROR" for several different error scenarios (unique property constraint violation, invalid enum values etc). Hubspot seems to know the specific error case, as it is described in the message text, but there is no progrematic way to determine this.

 

Obviously one could try to parse information out of the message text, however this is not a reliable way to decode the information.

 

@hubspot - Please add a detailed HTTP-400 error subcategory / error code attribute with formally defined values that match the error text so that we can make our integrations robust/reliable.