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.
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:
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.
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.
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.
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: