Hi,
I try to use TArray< T > as input parameter for a get request. Is that supported? And if not, how could this be solved without individual requests per element?
The server throws the following error when starting:
Projext XXX.exe raised exception class EUnsupportedActionParamType with the message 'Cannot define action "test": Invalid type "TArray<System.Integer>" for param "test"
I tried TArray< T > and array of T. The last runs, but does only convert one of the parameters in an array.
The interface:
unit UnLMS_Service_Ritten_INT;
interface
uses
XData.Service.Common,
system.Generics.Collections,
System.JSON;
type
[ServiceContract]
[Route('ritten')]
IRittenService = interface(IInvokable)
['{6C57E613-CCAA-4883-AE82-915F6CB705C2}']
[HttpGet] function test(test: TArray<integer>): integer;
end;
implementation
initialization
RegisterServiceType(TypeInfo(IRittenService));
end.
The function in the implementation:
function TRittenService.test(test: TArray<integer>): integer;
begin
result := 1;
end;
The call with postman (java - Send an Array with an HTTP Get - Stack Overflow):
http://192.168.1.1:9997/app/ritten/test?test[]=1&test[]=3
It works when the request is defined as POST with the array in the body.