Company XML Parsing Error

Hello, I am getting a strange parsing error on some of my requests to get information from any table regarding companies; I was wondering if anybody has seen this before.

The first time I received this error it was with a company Sechler CPA PC, so I removed it from the query but another popped up and I was just hoping to understand the root problem here so that I can fix it or get around it because currently it is stopping me from getting company information since it is a fatal error. Thanks for the help!

Hi @Rameal_Nabeeh, can you post a snippet of the code that is causing this error to happen?

Absolutely, it looks like this

$allContacts = [];
$table = "Contact";
$limit = 1000;
$page = 0;
$dated = (string) date("Y-m-d");
$queryData = array(
  "LastUpdated" => "~<~ ".$dated." 00:00:00"
$selectedFields = array(
$orderBy = "LastUpdated";
$ascending = true;
while($contact = $infusionsoft->data()->query($table, $limit, $page, $queryData, $selectedFields, $orderBy, $ascending)){
  if($page > 50)
  $allContacts = array_merge($allContacts, $contact);

The above code works but once I change the array to include Company it throws that error from the original message.

I’m guessing that there is a company name that has an invisible character that is causing the XML returned to be invalid.

We have run into similar issues over a dozen times. Somehow an “invalid” character gets into a record (we usually see it on Contacts, but it can be on any object) and it crashes everything since it totally kills the API request and throws that fatal error into the script.

The best solutions we’ve come up with for this is hacking the file in our SDK to filter out all of the invalid characters that have given us problems before the xml is parsed. It is definitely an imperfect solution, but it has been working for us for a couple of years now. You can use our SDK that has this filtering built in or grab the lines you need out of the file that we use.

That worked! I really appreciate the help everybody if there is a like a review site let me know because this is probably the most helpful/responsive forum I’ve been a part of.

1 Like