You are not logged in.
I want to send as a parameter TSQLRecordClass, I know I can run on the server to retrive the correct table. (This function will be executed from multiple tables)
procedures in my server side is
procedure TFileServer.DataFromID(var Ctxt: TSQLRestServerCallBackParams);
var //aData: TSQLRawBlob;
sfilename:RawUTF8;
Id:Integer;
RecordClass: TSQLRecordClass;
AObject:TSQLObject;
begin
sfilename :='';
if not UrlDecodeNeedParameters(Ctxt.Parameters,'ID') then begin
Ctxt.Error('Missing Parameter');;
{$ifNdef SERVICE}
writeln('invalid Request');
{$ENDIF}
exit;
end;
while Ctxt.Parameters<>nil do begin
UrlDecodeInteger(Ctxt.Parameters,'ID=',Id,@Ctxt.Parameters);
UrlDecode(Ctxt.Parameters,'RECORDCLASS=',RecordClass,@Ctxt.Parameters);
end;
AObject := TSQLObject(RecordClass.Create);
if Self.Retrieve(id,AObject,false) then
begin
sfilename := AObject.filename;
Ctxt.Results([sfilename]);
end
else
begin
Ctxt.Error('invalid Request');
exit; // we need a valid record and its ID
end;
end;
Offline
You should better use the RESTful URI parameters, already existing in Ctxt.
See TSQLRestServerCallBackParams.Table and TSQLRestServerCallBackParams.ID parameters on the server side, and the normal URI encoded as REST, via Table and ID parameters of TSQLRestClientURI.CallBackGet()/CallBackGetResult() methods.
The documentation states it.
Offline
sorry for the delay in answering, but before I tried if it worked. and it works
..
// - use TSQLRest.Retrieve(Reference) to get a record value
AObject := TSQLObject(self.Retrieve(RecordReference(Model,Ctxt.Table,Ctxt.ID)));
Ctxt.Results([(AObject.filename]);
...
thanks
Offline
Don't forget to release the TSQLRest.Retrieve(Reference) instance, otherwise you will leak memory.
Using a Reference value will work here, but I suspect the more native could be to work at RESTful URI level, using:
- TSQLRestClientURI.CallBackGet()/CallBackGetResult() methods for client;
- TSQLRestServerCallBackParams.Table and TSQLRestServerCallBackParams.ID parameters on the server side.
Offline
ok thanks
Offline