SAP Knowledge Base Article - Public

2359742 - How to use $count / How to verify the output records in an Odata API call?

Symptom

How to count or verify the nro of output records through Odata API.

This is helpful to troubleshoot or investigate issues with missing records in the output file.

Environment

Successfactors

Resolution

Append /$count after the root entity in an Odata API query call.

Example shown below.

API Request

/odata/v2/EmpEmployment/$count?$expand=personNav/personalInfoNav,personNav/emailNav/emailTypeNav,jobInfoNav/companyNav,jobInfoNav/businessUnitNav,jobInfoNav/costCenterNav,jobInfoNav/divisionNav,jobInfoNav/locationNav,jobInfoNav/emplStatusNav/picklistLabels,jobInfoNav/employeeClassNav/picklistLabels,jobInfoNav/managerUserNav,jobInfoNav/employmentTypeNav/picklistLabels,personNav/phoneNav/phoneTypeNav,userNav&$filter=personNav/personalInfoNav/firstName%20ne%20null&$orderby=personNav/personalInfoNav/firstName

API Response

25121

Screenshot of the same.

25121.png

Similarly,

/odata/v2/User/$count

This gives the output of number of active users in the SF instance.

Note1, please do not send the API call with encoded filters, like base 64 enconded =  /odata/v2/PerPersonal/$count?$filter=Zmlyc3ROYW1lIGVxICdUZXN0Jw==  (this will result in HTTP 404 errors)

Note2, in case you are with error like "Entity $count is not found. Please contact your system administrator", please refresh the odata metadata cache and try again. Find instructions in the KBA 2171588.

Keywords

usage of $count, OData, Succesfactors, Records , KBA , LOD-SF-INT , Integrations , LOD-SF-INT-API , API & Adhoc API Framework , How To

Product

SAP SuccessFactors HXM Core all versions