SAP Knowledge Base Article - Public

2802329 - "Invalid Token Detected" Error When Performing a Filter in Odata Query

Symptom

When performing an Odata query with a filter defined for a text field, the following error message is returned:

Invalid Token Detected at Position X (where X represents the position of a character from the query)

Environment

SAP Cloud for Customer.

SAP Business ByDesign.

Reproducing the Issue

Perform a query using an Odata URL, and defining a filter for a text field. For example:

https://myXYZ.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ContactCollection?$filter=Email eq "abc'def@mydomain.com"

Cause

You are using a special character such as single or double quote (' or ") in the field value. As the Odata API uses these characters to limit the begin and the end of the values to be filtered, they are not properly handled by the system, causing the error.

Resolution

Perform the query suppressing the special character. In the example above mentioned in the Reproducing the Issue section, the e-mail of the filter should be inserted as "abcdef@mydomain.com".

The Odata API is capable of identifying the value even without the special characters.

Keywords

 OData, Invalid Token Detected, Custom OData, Error, characters. , KBA , AP-RC-ODF , OData framework (C4C Only) , AP-RC-ODF-BYD , OData Framework and Console (ByD) , How To

Product

SAP Business ByDesign all versions ; SAP Cloud for Customer add-ins all versions