I have a simple service contract for authentication:
[ServiceContract]
IAuth = interface(IInvokable)
['{20BBDF2D-CA6B-4CCA-92DB-59A038EE2679}']
function Login(const Email, Password: string): TLoginResult;
end;
where TLoginResult is a PODO which contains within it another PODO.
[JsonInclude(TInclusionMode.Always)]
TLoginUser = class
private
Fname: string;
Femail: string;
Fid: string;
public
property id: string read Fid write Fid;
property name: string read Fname write Fname;
property email: string read Femail write Femail;
end;
[JsonInclude(TInclusionMode.Always)]
TLoginResult = class
private
FUser: TLoginUser;
FaccessToken: string;
public
constructor Create;
destructor Destroy; override;
property user: TLoginUser read FUser write FUser;
property accessToken: string read FaccessToken write FaccessToken;
end;
The constructor and destructor for TLoginResult just create and destroy the FUser object.
When I compile this into a (linux) apache module and call the API using PostMan, I get a message to say that it caused the server to return an unkown error 520 (!).
If I remove the user property, it works, but the web framework I use needs a separate user object to be returned (or lots of web code needs to be refactored).
From the manual, it looks like it should be possible to return a nested PODO like this, so I assume I am doing something daft...
Any suggestions for how to do this correctly?
- Niels