Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2022-09

rpcclient without parameters doesn't work

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Hello,

I see that if I try to use a method without parameters, e.g.

StartParams;
_Params:=EndParams
Result:=ExecuteRequest(RPCClassName,'logout',_Params, at DoSuccess,aOnFailure);

it triggers an error in the server

Cannot determine parameters: No "params" property found in request.

Debugging in the browser I see that in method TRPCClient.DoSendBatch (packages/fcl-rpc/fprpcclient.pp), the condition

if Assigned(aRequest.Params)

evaluates to false, even if aRequest.Params is there (though it's an empty array).

Bye

Luca
Mattias Gaertner
to Luca Olivetti
Show quoted text 5 lines
[...] if Assigned(aRequest.Params) evaluates to false, even if aRequest.Params is there (though it's an empty array).

An empty Pascal array can be nil so Assigned(nil) can be false.

Mattias

Luca Olivetti
to Mattias Gaertner

El 13/9/22 a les 14:38, Mattias Gaertner ha escrit:

Show quoted text 10 lines
On Tue, 13 Sep 2022 09:22:33 +0000 (UTC) Luca Olivetti wrote: > [...] > if Assigned(aRequest.Params) > > evaluates to false, even if aRequest.Params is there (though it's an > empty array). An empty Pascal array can be nil so Assigned(nil) can be false.

Then either the condition is wrong or there should be an "else" to assign aSerialized['params'] no matter what.
Or modify the server to accept a missing 'params' in the json instead of erroring out.

Bye

Luca