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.
| Error | HTTP | Cause | Resolution |
|---|---|---|---|
SYNTAX_ERROR | 400 | Missing select / from, or unbalanced parentheses. | Provide a well-formed query with a base module. |
SYNTAX_ERROR | 400 | Statement other than select (e.g. update, delete). | Only select is supported. |
SYNTAX_ERROR | 400 | as not followed by an alias. | Supply a non-empty alias after as. |
INVALID_QUERY | 400 | Unknown field or module name. | Use the exact field / module name as defined. |
INVALID_QUERY | 400 | Comparator not allowed for the field's type. | Use a comparator valid for that field type. |
INVALID_QUERY | 400 | Value type does not match the field's data type. | Pass a value matching the field's type. |
INVALID_QUERY | 400 | Aggregate used on a non-numeric field (other than count). | Apply aggregates only to numeric fields. |
INVALID_QUERY | 400 | Aggregate mixed with scalar fields but no group by. | Add a group by listing every scalar select field. |
INVALID_QUERY | 400 | A multi-line field (e.g. Description, Comments) used in where. | Remove multi-line fields from the criteria. |
DUPLICATE_DATA | 400 | Duplicate select columns or duplicate alias. | Remove duplicate columns; use unique aliases. |
LIMIT_EXCEEDED | 400 | A 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. |
UNAUTHORIZED | 401 | Caller lacks read access to the module. | Obtain the required permission. |
INTERNAL_ERROR | 500 | Unhandled server exception. | Retry; contact support if it persists. |
tip
For the exact thresholds behind LIMIT_EXCEEDED, see Limits & Validations.