errors in PHP calls to Insightly API
Getting an error when I try to post a form through AJAX to PHP and create a new Contact with the Insightly API. I think the error has to do with the way the form data gets encoded and added to the JSON object, but I've been unable to tell specifically what characters are causing the error. There doesn't seem to be a pattern--sometimes it breaks when you enter one word, no special characters, other times you can post in all sorts of commas, apostrophes etc with no issue.
The PHP that posts to Insightly is here:
(I did not write this; I'm taking over for the original developer)
The error log:
Message: Exception: Bad HTTP status code: 400
InsightlyRequest::asString called at [/app/assets/php/insightly.php:1539]
InsightlyRequest::asJSON called at [/app/assets/php/insightly.php:236]
Insightly::addContact called at [/app/assets/php/insightly_send.php:126]
where all the post variables are form field data.
I know it has to do with that comment field but can't determine how or if to sanitize the form input so this doesn't happen.
This is more of a general PHP question rather than specific to Insightly but hoping someone has had a similar issue or can provide insight (heh)