HttpAPI on ComplexType and DateTime


I define a complexType

  {$REGION 'structs'}
  TIopMem = class(TROComplexType)
    fTrdName : String;
    fEngName : String;
    fBirthday  : TDateTime;
    property TrdName: String read fTrdName write fTrdName;
    property EngName: String read fEngName write fEngName;
    property Birthday: TDateTime read fBirthday write fBirthday;

  TIopMemCollection = class(TROCollection<TIopMem>);

 function GetMemList([ROCustom('httpapiheaderparameter', '1')] const SWHERE: UnicodeString): TIopMemArray;

 function AddMemList(iopdata: TIopMem): integer;

First , The datatime, it seems added timezone on TdateTime and return back
original is 2000/1/1 but return to client is 1999-12-31T16:00:00Z. How to cancel the timezone or how to convert?

function TDataService.AddMemList(iopdata: TIopMem): integer;
  Result := 1;

Also When I use addmem pass TIopMem to server , I can get return 1 but the pass-in Tiopmem cannot get any value.

how to solve?




as expected. if you return date as 2000/1/1 UTC+0, client will recieve 2000-01-01T00:00:00Z

check my answer at Result datetime has 1 day difference when returning only a date.

Thanks , how about the addmem pass complextype as json from client, I cant read it in server . any suggestion?


I can’t reproduce this case. everything works as expected:

>curl -v -X POST "http://localhost:8099/api/addmem" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{  \"iopdata\": {    \"Birthday\": \"2020-08-20T09:09:47.498Z\",    \"EngName\": \"EngName11\",    \"TrdName\": \"TrdName333\"  }}"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1:8099...
*   Trying
* Connected to localhost ( port 8099 (#0)
> POST /api/addmem HTTP/1.1
> Host: localhost:8099
> User-Agent: curl/7.72.0
> accept: application/json
> Content-Type: application/json
> Content-Length: 116
* upload completely sent off: 116 out of 116 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: close
< Content-Type: application/json; charset=utf-8
< Content-Length: 1
< Date: Thu, 20 Aug 2020 09:14:17 GMT
< Accept-Encoding: gzip, identity
* Closing connection 0

can you retest this issue with curl, pls?

note: curl request can be generated with

Thanks my fault on postman I did not select json type for the body data.