SAP Knowledge Base Article - Public

2691670 - ODATA API: Searching Special Characters


This document has been created to outline the standardized methods of filtering OData API output based values that contain special characters.

You perform Odata API Request and are performing $filter= operation on a field in which the value contains special characters:

Example Response (JSON):



    "error": {

        "code": "ServerErrorException",

        "message": {

            "lang": "en-US",

            "value": "String index out of range: 68"




Example Response (XML):

            <value>String index out of range: 68</value>


  • SuccessFactors BizX
  • OData API

Reproducing the Issue

To reproduce the issue, the below actions can be performed:

  1. Example: a user with a name similar to the following: Admin O'Data --> firstName eq 'Admin' lastName='O'Data'
  2. Example API Request:$filter=firstName eq 'Admin' and lastName eq 'O'Data'
  3. An error similar to those outlined in the above 'Symptom' section, will be returned

There is an apostrophe contained in the value of lastName that the filter operation is being applied to.

Essentially the request would looking for a value of 'O' in the above API request example,

The Data' part of the call that follows, would be considered bad syntax for the API request


In OData there is handling built in for special characters,

This has to be used when searching for field values that may contain a special characters


For apostrophe, use two apostrophe to escape it:

  • Example: $filter=lastName eq 'O'Data' ---> $filter=lastName eq 'O''Data' (this will return the User record when applied to the above call)


For '#', use %23:

  • Example: $filter=division eq 'ABCD#'  ---> $filter=division eq 'ABCD%23'


For '&', use %26:

  • Example: $filter=department eq 'R&D'  ---> $filter=department eq 'R%26D'


For other special characters:

  • Use raw value


  • Special Characters, OData, API, Request, Query, #, &, Apostrophe
, KBA , LOD-SF-INT , Integrations , LOD-SF-INT-ODATA , OData API Framework , How To


SAP SuccessFactors HCM Core all versions