SAP Knowledge Base Article - Public

3028227 - OData response structure behavior in navigations

Symptom

What is the OData response structure behavior when using expand?

Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

  • SAP SuccessFactors HXM Suite
    • OData API

Resolution

When you have a field in the response of your OData query which is originated from a navigation (expand), the expected behavior of OData is to write it as below:

Query

https://apisalesdemo4.successfactors.com/odata/v2/Position?$select=code,parentPosition/code&$expand=parentPosition&$filter=code eq '5000359'

Response in XML

<Position>
 <Position>
  <parentPosition>
   <Position>
    <code>50026026</code>
   </Position>
  </parentPosition>
  <code>5000359</code>
 </Position>
</Position>

Response in JSON

"results": [
            {
                "__metadata": {
                    "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/Position(code='5000359',effectiveStartDate=datetime'1990-01-01T00:00:00')",
                    "type": "SFOData.Position"
                },
                "code": "5000359",
                "parentPosition": {
                    "__metadata": {
                        "uri": "https://apisalesdemo4.successfactors.com:443/odata/v2/Position(code='50026026',effectiveStartDate=datetime'2020-11-17T00:00:00')",
                        "type": "SFOData.Position"
                    },
                    "code": "50026026"
                }
            }
        ]

It will always write the name of the navigation (parentPosition) and inside its tag (the lines below it, inside the brackets), the fields that were requested in the $select parameter (in this case "code" field). If no specific fields from the navigation are requested in the $select (if you just put as $select=parentPosition), all fields from the parentPosition record will be returned inside its tag.

This is the standard behavior and can't be changed.

Keywords

structure, navigation, relation, relationship, expand, query, api, odata, sf, successfactors, result, response, request, , KBA , LOD-SF-INT-ODATA , OData API Framework , How To

Product

SAP SuccessFactors HXM Suite all versions