SAP Knowledge Base Article - Public

2694988 - Error "Cannot cast class java.lang.Integer to class java.lang.Long" when execute API call


When execute the ODATA API Call, error "ServerErrorException" returned with message "Cannot cast class java.lang.Integer to class java.lang.Long".



Reproducing the Issue

For example:

  • Execute ODATA API call /odata/v2/getUsersByDynamicGroup?groupId=123
  • System will return below error:
    ""error": {
    "code": "ServerErrorException",
    "message": {
    "lang": "en-US",
    "value": "Cannot cast class java.lang.Integer to class java.lang.Long"


The format of the parameter that is causing the issue. Please check in OData API Data Dictionary for the corresponding field, like groupId in this example, it has type "Long" but the value (123) given here is in type Integer.


Ensure there is an "L" added to the integer. Please also refer to the SAP SuccessFactors HCM Suite OData API: Reference Guide:
in which there has below example you can use has reference to see how the parameter should format.
Request Sample:http://<Hostname>/odata/v2/getUsersByDynamicGroup?groupId=7228l


Integer; Long; ServerErrorException; java.lang.Integer; java.lang.Long; cast , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , Problem


SAP SuccessFactors HCM Core 1808