Formatting an HTTP get response

Below is the data being returned by an XDataServer using a get request. I'm wondering what options there are to format this data.

  • Can it return just the array of data (removing the "value" object)
  • Can we map the field names to an alias so they export using the alias rather than the actual database field names (i.e. COMP_ID could be exported as compID)

Also, are we able to "intercept" the url passed so we could reformat the syntax on any filtering in the url to a format xdata understands (or possibly interpret it and apply the filter directly)?

{
"value": [
{
"$id": 1,
"COMP_ID": "A",
"NAME_COMP": "Company A",
"STREET": null,
"PROVINCE_ID": "_"
},
{
"$id": 2,
"COMP_ID": "C",
"NAME_COMP": "The C company",
"STREET": "123 this is it street",
"PROVINCE_ID": "MN"
}
]
}

Is that a result of invoking a service operation or requesting a CRUD endpoint? In this case:

  1. You can't return just the array of data

  2. You can change the property names from code by modifying the model. Here is an example:

uses {…}, XData.Aurelis.Model, XData.Model.Classes;
 
var
  XType: TXDataEntityType;
begin
  XType := TXDataAureliusModel.Default.FindEntityType('vInsuredEnds');
  XType.FindProperty('DateAdd').Name := 'Date Added';
  XType.FindProperty('Filename').Name := 'File’;

You can intercept and modify any request by using the middleware system (using a generic or custom middleware): https://download.tmssoftware.com/business/sparkle/doc/web/middleware.html

This was retrieved by an http get request from a javascript application.
I looked at the link and it says the response can be modified by tapping into the OnHeaders method of the response object. We could modify the response to remove the "value" object and just return the data array could we not?

Yes, you could. Not very straightforward, but totally possible.