SAP Knowledge Base Article - Public

3786250 - OData API Navigation Behavior for Composite-Key Entities With and Without $expand

Symptom

When querying an OData entity that contains a navigation property to a related entity with a composite key, the response may differ depending on whether the navigation property is expanded or not.

Customers may observe that the composite-key fields of the related entity are visible when the navigation property is requested with $expand, but are no longer present when $expand is removed. This can lead to the assumption that the composite key has been collapsed, removed, or modified.

     

Example:

Request without $expand: https://api68sales.successfactors.com/odata/v2/PerPerson('666')?$format=json

  • Response:

    "emailNav":
    {
            "results": [
                {
                    "__metadata": {
                        "uri": "https://api68sales.successfactors.com/odata/v2/PerEmail(emailType='8446',personIdExternal='666')",
                        "type": "SFOData.PerEmail"
                    },
                    ...,
                {
                    "__metadata": {
                        "uri": "https://api68sales.successfactors.com/odata/v2/PerEmail(emailType='8447',personIdExternal='666')",
                        "type": "SFOData.PerEmail"
                    },

Request with $expand: https://api68sales.successfactors.com/odata/v2/PerPerson('666')?$format=json&$expand=emailNav

  • Response:

    "emailNav":
    {
            "__deferred": {
                "uri": "https://api68sales.successfactors.com/odata/v2/PerPerson('666')/emailNav"
            }
        }

Environment

SAP SuccessFactors HCM Suite

Reproducing the Issue

  1. Query a parent entity with a navigation property expanded (for example, emailNav).
  2. Observe that the related composite-key entities are returned inline.
  3. Remove the $expand parameter and execute the same query.
  4. Observe that only the navigation reference is returned and the related entity key fields are no longer present.

Resolution

This is expected OData behavior.

emailNav is a navigation property pointing to related PerEmail entities. The OData specification defines navigation properties as relationships to other entities or collections of entities. Related entities are returned inline only when explicitly requested through $expand.

PerEmail is identified by a composite key (emailType, personIdExternal). When $expand=emailNav is used, the related PerEmail entities are serialized inline and their key fields are visible. When $expand is removed, OData returns only a navigation reference to the related collection and does not serialize the related entities. Consequently, the composite-key fields are not included in the parent entity response.

The composite key is not collapsed, modified, or lost; the related entities are simply not included in the payload because they were not requested through $expand.

Reference: https://www.odata.org/documentation/odata-version-2-0/uri-conventions/

See Also

OData, OData API, OData V2, Navigation Property, Navigation Properties, $expand, expand query option, expanded navigation, deferred navigation, deferred URI, inline entities, entity navigation, related entities, entity relationships, composite key, composite keys, composite-key entity, multi-key entity, key predicate, entity key, PerEmail, emailNav, PerPerson, parent entity, child entity, navigation collection, navigation reference, OData URI conventions, OData standard, OData specification, OData behavior, expected behavior, entity serialization, inline serialization, entity materialization, navigation link, deferred link, related collection, expanded response, non-expanded response, key visibility, composite key visibility, OData response structure, OData query, SAP SuccessFactors OData API, SuccessFactors API, API navigation behavior, OData navigation collection, entity association, association navigation, OData entity relationship, query expansion, navigation path, entity retrieval, OData best practices, OData protocol standard, OData key fields, emailType, personIdExternal, API response difference, $expand behavior, without $expand, with $expand, navigation property expansion, OData metadata, OData URI, entity addressing, key predicate representation, composite primary key, related entity collection, navigation property serialization, deferred navigation property, expanded navigation property, entity collection navigation, API expected result, standard OData behavior, OData compliance, OData navigation semantics, SuccessFactors OData V2, navigation entity keys, composite-key navigation entities, related entity keys, child entity keys, email navigation entity, OData reference implementation, URI Conventions OData V2, OData entity model, OData relationship model, OData query options, system query options, navigation property collection, OData response payload, entity expansion behavior, navigation property URI, inline navigation data, deferred navigation data

Keywords

odata v2, $expand, composite key, to-many navigation, primary row, picklist, type decoder, PerEmail, emailNav, emailTypeNav, PerPhone, PerAddress, PerNationalID, PerEmergencyContacts, employee central , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT-EC , Employee Central SFAPI & OData Entities , How To

Product

SAP SuccessFactors HCM Suite all versions