Skip to main content

Errors

When a query cannot be executed, FOQL returns an error code and an HTTP status. The table below lists the possible errors, their causes, and how to resolve them.

ErrorHTTPCauseResolution
SYNTAX_ERROR400Missing select / from, or unbalanced parentheses.Provide a well-formed query with a base module.
SYNTAX_ERROR400Statement other than select (e.g. update, delete).Only select is supported.
SYNTAX_ERROR400as not followed by an alias.Supply a non-empty alias after as.
INVALID_QUERY400Unknown field or module name.Use the exact field / module name as defined.
INVALID_QUERY400Comparator not allowed for the field's type.Use a comparator valid for that field type.
INVALID_QUERY400Value type does not match the field's data type.Pass a value matching the field's type.
INVALID_QUERY400Aggregate used on a non-numeric field (other than count).Apply aggregates only to numeric fields.
INVALID_QUERY400Aggregate mixed with scalar fields but no group by.Add a group by listing every scalar select field.
INVALID_QUERY400A multi-line field (e.g. Description, Comments) used in where.Remove multi-line fields from the criteria.
DUPLICATE_DATA400Duplicate select columns or duplicate alias.Remove duplicate columns; use unique aliases.
LIMIT_EXCEEDED400A limit was exceeded — e.g. >2,000 records, >5 joins, >25 where conditions, >10 order by fields, >4 group by fields, or >5 aggregate fields.Reduce the query below the documented limit.
UNAUTHORIZED401Caller lacks read access to the module.Obtain the required permission.
INTERNAL_ERROR500Unhandled server exception.Retry; contact support if it persists.
tip

For the exact thresholds behind LIMIT_EXCEEDED, see Limits & Validations.