SAP Knowledge Base Article - Public

2819492 - Handling Special Characters in an OData API Url

Symptom

Guidance on how to correctly handle special characters in OData API URLs, including which characters are restricted and require percent‑encoding.

Environment

  • SAP SuccessFactors HCM Suite
    • OData API

Resolution

1. Overview

When constructing OData API URLs, certain characters cannot be used directly because they may break the URL or cause server‑side parsing errors. These characters must be percent‑encoded according to URL encoding standards.


2. Restricted Characters (Must Be Percent‑Encoded)

The following characters cannot be used directly in an OData URL:

  • Space ( )
  • Double quote (")
  • Hash (#)
  • Percent (%)
  • Ampersand (&)
  • Plus (+)
  • Question mark (?)
  • Slash (/)
  • Backslash ()
  • Colon (:)
  • Semicolon (;)
  • Less than (<)
  • Greater than (>)
  • Equal sign (=)
  • Pipe (|)
  • Caret (^)
  • Tilde (~)
  • Square brackets [ ]
  • Curly braces { }
  • Backtick (`)

These characters must be replaced with their percent‑encoded equivalents (e.g., space → %20).


3. Non‑Restricted Characters

These characters can be used safely in OData URLs without encoding:

  • Letters (A–Z, a–z)
  • Numbers (0–9)
  • Hyphen (-)
  • Underscore (_)
  • Period (.)
  • Exclamation mark (!)
  • Dollar sign ($)
  • Asterisk (*)
  • Apostrophe (')
  • Parentheses (( ))

4. Encoding Examples

CharacterEncoded Form
Space%20
"%22
#%23
%%25
&%26

5. Example URL

Original URL (contains restricted characters):

https://api.example.com/odata/Product('ABC 123')?$filter=Price gt 20&Category='Electronics & Gadgets'

Corrected with percent‑encoding:

https://api.example.com/odata/Product('ABC%20123')?$filter=Price%20gt%2020&Category='Electronics%20%26%20Gadgets'

Additional Information

A full list of restricted and non‑restricted characters can be found in the SAP Help Portal:
https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/latest/en-US/c39284943ddd4476bdbd9d2b66e01abe.html

Keywords

OData, API, URL, Special Characters, Restricted Characters, Percent-Encoding , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , Problem

Product

SAP SuccessFactors HCM Suite all versions