SAP Knowledge Base Article - Public

2737577 - How does the server orders the fields in OData responses - OData API

Symptom

When I am performing an OData call, the system does not order the fields accordingly to the order that I use in my query.

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 Recruiting Management

  • Job Requisition;

SAP SuccessFactors

  • OData API (all entities).

Reproducing the Issue

  1. Using as an example the Job Requisition entity, perform the following call: [data_center_uri]/odata/v2/JobRequisition?$select=jobReqId,country,division,department,location
  2. Notice that the order that I have set is: 
    1. jobReqId
    2. country
    3. division
    4. department
    5. location
  3. Now, once I run the query, the system will return the following result:
    rep_3.jpg
    Notice that the order comes as: jobReqId, division, country, location, department, Which is not alphabetical order, or the $metadata order, neither the one we have set on our $select.

Resolution

This is how the system behaves, for you to understand in which order the fields will come when you perform a query, you can perform a query without a $select parameter, to see which will be the order.

  1. Still using the Job Requisition as our entity to query, run the following query: [data_center_uri]/odata/v2/JobRequisition?$top=1
  2. The result of this query will be a huge amount of fields, which are all the fields in the entity that you queried on, and the respective order as they will come if you perform any query on it;

Keywords

OData, order, query, top, select, fields, entity, response, metadata , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , LOD-SF-RCM-API , Webservices & APIs , How To

Product

SAP SuccessFactors HCM Core all versions ; SAP SuccessFactors HCM suite all versions ; SAP SuccessFactors Recruiting all versions