This is not an API error but one caused by the SQL syntax in the custom whereClause. To troubleshoot this issue, examine the SQL syntax carefully in your statement. Some things to look for:

1. If using multiple lines, check for blank spaces left out at the end of each line. This will cause the entire SQL string to concatenate and be read as one long string. For example:

 "RECORDS.ID IN (SELECT RECORDS.ID FROM RECORDS AS RECORDS" +
 "WHERE RECORDS..." 


The space missing at end of the highlighted section above would result in RECORDSWHERE.

2. Missing escape characters or closing brackets. For example:

 "WHERE(RECORDS.IS_CONSTITUENT = -1"