SAP Knowledge Base Article - Public

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

Symptom

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

Environment

Successfactors

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"
    }
    }"

Cause

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.

Resolution

Ensure there is an "L" added to the integer. Please also refer to the SAP SuccessFactors HCM Suite OData API: Reference Guide:
https://help.sap.com/doc/74597e67f54d4f448252bad4c2b601c9/latest/en-US/SF_HCM_OData_API_REF_en.pdf
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

Keywords

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

Product

SAP SuccessFactors HCM Core 1808