The following contents covers an overview of the EC OData API Basics.
Objective
The following contents covers an overview of the EC OData API Basics.
We will introduce 3 test clients for EC OData API. The first one is Soap UI, it can be used for both SOAP and REST, and it allows complex test script creation including load tests. The second is the JMeter, it also can be used for both SOAP and REST/OData. The last one is Firefox Rest client and can be used for any Rest based API including OData.
SOAP UI
JMeter
Firefox addon Rest Client
As we known, there will be the identity authentication when we call OData API, we can call it Basic Authentication. Generally speaking, we send authentication with the https header by parameter Authorization. Base 64 encode string username@companyId:passwordcombine with word Basic and a space in front of it. (In fact all of the test clients will provide us the parameter of Authorization, we just need to set theusername@companyId and the password, then the Base 64 encode string will be created automatically according to your input in the Authorization.)

OAuth with SAML assertions
See OData Documentation
OData API supports on some http operations like GET, POST, PUT, PATCH and DELETE, we use the basic operations to get or edit the entities like User, PerPerson, picklist and so on in EC
HTTP Operations
HTTP Resources or Services
HTTP Parameter
XML Definition of API metadata
In order to get extra information, such as language labels, picklists, beyond what the standard OData metadata provides, SAP Successfactors OData exposes metadata as an entity. The SAP SuccessFactors OData API exposes an entity named 'Entity'. Its properties are exposed as complex type value embedded in the response body of 'Entity'. Different forms of metadata can thus be exposed without changing the standard OData metadata format. You can access the new metadata just like you would access a regular entity. In addition, it supports a simple filter to output metadata of a specific entity.
The metadata can be achieved via OData API by $metadata in the https call. You can request for the metadata via Firefox Rest Client. Because the data is a little large for the metadata, the request may takes more time.

Select the play button to learn about the $format parameter.
Filter options and parameters
The below example shows an OData API query example using filter and select. For the filter we can give a specified value to a field to query on the corresponding entity. For the select we can also define the fields to return the response.
%20 is special escape character for space; like %28 and %29 is for brackets like "(" and ")"
Available operators are EQ,NE,GT,GE,LT,GT and those can be combined with NOT, AND and OR
$select=firstName defines fields to be returned separated by spaces

The below example shows how to use the parameter of expand. Expand always used to navigate to other entity.

Expanding the data – navigating the data model
expands firstName in root resource and all fields in navigated resource person
$select=firstName,personNav/dateOfBirth
expands firstName in root resource and all fields in navigated resource person


The above example shows us how to use the parameter of $expand and $filter
The response identifies a set of User Entities whose personNav/emailNav property is emailAddress which is equal to gerald.reinhard@sap.com, After the entities are retrieved, the response removes unselected columns. Then the $expand option expands the selected columns that is a navigation property
Deep Filtering using $filter and $expand

Filter+Expand


The below content describes how to query effective-dated entities, to use fromDate and toDate will return all historic data of root entity in the response. But if the root entity is not effective date, the fromDate and toDate will be applied to the next effective dated entity in the navigation hierarchy, and all of the effective dated records falling into the time interval between fromDate and toDate will be returned.
Also If historic data of an effective dated record is returned and a navigation/expand from those records to another effective dated record is done the start date of the first effective dated entity will be used to filter the 2nd one.
This describes how to query effective-dated entities, to use fromDate and toDate will return all historic data of root entity in the response. But if the root entity is not effective date, the fromDate and toDate will be applied to the next effective dated entity in the navigation hierarchy, and all of the effective dated records falling into the time interval between fromDate and toDate will be returned.
Also If historic data of an effective dated record is returned and a navigation/expand from those records to another effective dated record is done the start date of the first effective dated entity will be used to filter the 2nd one

The customer can choose between two types of Pagination:

When to use the different types of pagination:
And last but not least, we have optimized the OData entities FOLocation and FOPayGrade for snapshot-based pagination to improve performance.
Some additional basic features
A filter can be applied so that in EC OData API queries you can exclude external (non-EC) user data.
To make this possible, the following Boolean fields can be selected and used with $filter;
We’ve introduced the concept of a person UUID (unique universal identifier) for the entire SAP SuccessFactors HXM Suite; when a new hire or user is created, the system generates this identifier – called "perPersonUuid". perPersonUuid lets you expose the person UUID for integration and import scenarios for all employees (EC and non-EC employees).
The field is visible and upsertable in PerPerson but cannot be queried via this entity. To make perPersonUuid available in OData, we’ve created a new entity PersonKey. This entity cannot be directly queried but you can use $expand with personKeyNav in the User entity to expose the perPersonUuid. personKeyNav is exposed regardless of data model configuration, RBP or provisioning settings.
| Best Practice | Additional Notes |
|---|---|
| Use snapshot server pagination for integration use cases | If server pagination is not used, you can experience data loss or duplicates in your result set if simultaneous edits are occurring in the company instance. Snapshot often results in dramatic performance improvements as well. |
| Use "server pagination" to ensure a stable result set | Querying only records modified since your last execution instead of querying all records for integration use cases. |
| Don't try to simulate real-time by running jobs too often | Querying for periods much less than one hour will use too much API resources and may be throttled in the future. Running short 1/minute queries can result in a denial of service server situation, especially for complex queries that require a lot of back-end processing. |
| Reuse a login session instead of creating a session for each http transaction or each page of paginated data. | |
| Using an API for integration that is only designed for single user | Example: Iterating across all users and creating a session for each user. One example of this is the SFOData.Todo API which only allows querying data for a single user. The correct solution is to use the new TodoEntryV2 "Todo Export" permission. |
| Always add error checking for edit operations | Check for each item in the response. Log full error responses to your client log. Note: Do not rely on the API Center audit logs to check for errors. |
| Avoid too small a page size for paginated data | You should tune your batch sizes to be as large as possible. Note: There is a maximum of page size of 1000. For more complex transactions, you may need to decrease this value to avoid http timeouts. |
| Avoid large OData $expand statements | One example of this is an attempt to query all JobRequistions and then expand all JobApplications and all attachments for each application. Note: Such expands my be throttled in the future where a "Too Complex" or "Too large" error may be returned. |
| Avoid poor performance by keeping transactions simple. | Poor performance is often a sign of misuse of an API. |
| Avoid excessive multi threading | This can cause server issues and unreliable behavior. Often threading will not improve performance as it may cause data table contention. Note: Such threading may be limited by throttling in the future to protect servers. |
| Avoid deprecated APIs | SFAPI (excluding CompoundEmployee) and SFAPI Adhoc have been deprecated. Please use OData with snapshot pagination. |
| Do not query properties and expanded entities you do not need or use | It is easy to build a query that does more $select and more $expand than you need. Note: Integration Center avoids this, instead of a developer building a query manually based on the mapping of fields, IC generates the query based on the mapping. |
| Tune your client wait time to match the system wait time | Your client should be set to wait a reasonable amount of time before timing out. Long operations can run for as long as 7 minutes and our network and servers will continue to process a transaction for that long. It is best to wait for the transaction to complete (rather than just wasting the transaction without waiting for it to complete.) Note: You can also simplify your transaction to avoid timeouts in the first place. |
| Make use of API Tools like Data Model Navigator to tune queries | The Data Model Navigator can easily reveal available relationships to other entities, potentially simplifying your use case, while Preview Mode of the Integration Center can confirm that your results include the proper data within your responses. |
| Choose the optimal OData base entity | OData offers much flexibility from which to base a query but it is important to choose the best for your use case. For example, PerPerson is a better starting entity than PerPersonal. Using the latter increases lengths of all expand paths to email etc and results in poor performance. |
Don't pull many records 1 at a time with predicate key or singleton $filter queries instead of by batch or using $filter IN clause | This often happens querying from a list of keys, which is a common "in memory join" technique. filter with a key clause that checks for only a single entity instance. ie. &$filter=<key> eq <keyvalue> 2. Predicate key queries such as /odata/v2/User(userId='cgrant1') Recommendation: use OData join techniques or use the IN filter operator: $filter=key in ('cgrant1',mhoff1',....) |
This simulation demonstrates the basic configuration steps required to manually set up the configuration for SAP SuccessFactors Employee Central. You will get the basic knowledge of OData API call & Tools. How to monitor the APIs for different partners.
The following configuration and customization must have been completed before implementing Basic Settings in SAP SuccessFactors.
As part of this demonstration, we will cover configuration section in EC, which is: EC OData API Basics - REST Client.