PODO -> XData question

I have a class that's working and I want to move it into an XData service.

Here's the definition of a method in the Interface unit:

[HttpGet] function RunSnapshot( const SS_ID : string; aQryResp : TQryResp ) : TqrResults;

and in the Impl unit:

function RunSnapshot( const SS_ID : string; aQryResp : TQryResp ) : TqrResults;

and the classes:

[JsonInclude(TInclusionMode.Always)]
TqrResults = class( TList )
. . .
end;

[JsonInclude(TInclusionMode.Always)]
TQryResp = class
private
some strings . . .
FResults: TqrResults;
. . .
end;

When I try to run it, I get this exception:

First chance exception at $766046D2. Exception class EUnsupportedActionParamType with message 'Cannot define action "RunSnapshot": Invalid type "TQryResp" for param "aQryResp"'. Process Local_test_client.exe (5608)

How do I figure out what the exact problem is?

Maybe I need more info on how to send PODOs to service interfaces and get them back?

Can they have fields that are also objects?

I have a class that calls a 3rd-party API and it puts some results into member objects.

What I ultimately need is something more like this:

[HttpGet] function RunSnapshot( const SS_ID : string; aQryResp : TQryResp ) : TQryResp;

where the object aQryResp has two objects inside of it that are filled with more data and then returned. One is raw data (which is rather big and not typically needed), and the other (of type TqrResults) is results of some analysis of the raw data.

But it's choking on the aQryResp input.

Any suggestions on how to handle this situation?

Do you have any streams as fields of the object?

Change [HttpGet] to [HttpPost] (or just remove it, since POST is the default method). XData can receive PODO objects via GET, but only if they have simple properties or other PODOs. It can't receive, via GET method, an object that happens to have a list as one of the properties.

1 Like

That solved the problem! It's working now. Thanks!

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.