SAP SuccessFactors

API server addresses, OAuth2 authentication, the employee entity model and server-driven paging.

SuccessFactors exposes its HR data - users, employments, personal information, time off - through an OData V2 API with an entity model that spans hundreds of sets. An outgoing SAP connection pointed at the API server gives services access to all of them.

Connection settings

  • Address: https://apisalesdemo2.successfactors.eu/odata/v2 - the API server host depends on the data center your instance lives in
  • OData version: 2.0
  • Auth type: OAuth2 - SuccessFactors issues tokens through its own token endpoint, https://<host>/oauth/token
  • Needs CSRF token: disable it - SuccessFactors does not use the X-CSRF-Token exchange

The entity model

The core of the model revolves around a few entity sets:

  • User - accounts, names and contact data
  • EmpJob - employment details, positions, departments
  • PerPersonal - personal information
  • EmpTime - time off requests
conn = self.sap['SAP.SuccessFactors']

# Active users from one department, selected fields only
users = conn.read('User',
    filter="department eq 'Engineering' and status eq 't'",
    select='userId,firstName,lastName,email',
)

for user in users:
    self.logger.info('User -> %s %s', user['firstName'], user['lastName'])

Paging

SuccessFactors caps every page and returns __next links for the rest. Use .iter and the client follows the links until the result set is exhausted:

for user in conn.iter('User', filter="status eq 't'"):
    self.logger.info('Received -> %s', user['userId'])

Navigation properties connect the sets - a user's employment records, an employment's job information. The expand option reads them in one round trip:

users = conn.read('User',
    filter="userId eq '10001'",
    expand='empInfo/jobInfoNav',
)

Learn more