jptechon
(jptechon)
August 19, 2020, 2:40pm
1
Hi,
I define a complexType
{$REGION 'structs'}
TIopMem = class(TROComplexType)
private
fTrdName : String;
fEngName : String;
fBirthday : TDateTime;
published
[ROSerializeAsAnsiString]
property TrdName: String read fTrdName write fTrdName;
[ROSerializeAsAnsiString]
property EngName: String read fEngName write fEngName;
property Birthday: TDateTime read fBirthday write fBirthday;
end;
TIopMemCollection = class(TROCollection<TIopMem>);
{$ENDREGION}
[ROServiceMethod]
[ROCustom('HttpApiPath','memlist')]
function GetMemList([ROCustom('httpapiheaderparameter', '1')] const SWHERE: UnicodeString): TIopMemArray;
[ROServiceMethod]
[ROCustom('HttpApiPath','addmem')]
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;
begin
CodeSite.Send(iopdata.TrdName);
Result := 1;
end;
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?
Thanks
Joe
EvgenyK
(Evgeny Karpov)
August 19, 2020, 3:19pm
2
Hi,
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 .
jptechon
(jptechon)
August 19, 2020, 4:06pm
3
Thanks , how about the addmem pass complextype as json from client, I cant read it in server . any suggestion?
EvgenyK
(Evgeny Karpov)
August 20, 2020, 9:22am
4
Hi,
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 127.0.0.1:8099...
* Connected to localhost (127.0.0.1) 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
<
1
* Closing connection 0
can you retest this issue with curl, pls?
note: curl
request can be generated with https://editor.swagger.io/
jptechon
(jptechon)
August 20, 2020, 10:23am
5
Thanks my fault on postman I did not select json type for the body data.