Skip Navigation
Expand
Order of fields returned on REST API Response
Answer ID 11346   |   Last Review Date 01/27/2020

Can I change the order of the fields returned in REST API response?

Environment:

Oracle Field Service (OFS)

Issue:

I am trying to change/determine the order of the displayed fields on the API response to accommodate internal logic flow but the fields return in a different order.

Example:

When executing REST API call 'Search for Activities':

api.etadirect.com/rest/ofscCore/v1/activities/custom-actions/search?searchInField=XA_ANY_ORDER&searchForValue=00001&fields=apptNumber,status,date&dateFrom=2019-11-01&dateTo=2022-11-01&includeNonScheduled=true&includeMultiday=parents

I expect to receive the response in the below order:

{
   "totalResults": 3,
   "limit": 10,
   "offset": 0,
   "items":    [
            {
         "apptNumber": "ORCL-SCO00002",
         "status": "cancelled",
         "date": "2019-11-20"
      },
            {
         "apptNumber": "004003256453-0010",
         "status": "completed",
         "date": "2019-11-20"
      },
            {
         "apptNumber": "004003256453-0011",
         "status": "completed",
         "date": "2019-11-20",
      }

Resolution:

OFS does not allow for users to change the order of the fields presented on API response thus customers may not use the order of json fields returned on API commands on any internal logic.

The response for the above command will be:

{
   "totalResults": 3,
   "limit": 10,
   "offset": 0,
   "items":    [
            {
         "date": "2019-11-20",
         "apptNumber": "ORCL-SCO00002",
         "status": "cancelled"
   
      },
            {
         "date": "2019-11-20",
         "apptNumber": "004003256453-0010",
         "status": "completed"
      },
            {
         "date": "2019-11-20",
         "apptNumber": "004003256453-0011",
         "status": "completed"
      }