You are not logged in.
Pages: 1
Hi
How to easy process POST request in method-based service, i.e.:
- how to extract parameters from JSON payload?
- request Content type: text/plain or application/json?
- is it possible to use GetInputAsTDocVariant?
Regards, Tomek
Offline
Yes, I read:
https://synopse.info/files/html/Synopse … ml#TITL_49
http://blog.synopse.info/post/2010/07/1 … phi-7-2010
and unless I missed something, all of it with corresponding samples are related with GET request and extracting parameters from URI.
Offline
Check the https://synopse.info/files/html/api-1.1 … URICONTEXT documentation.
For the JSON body, you can use either JsonDecode(), or a TDocVariantData.
Offline
procedure TRemoteSrv.Test(Ctxt: TSQLRestServerURIContext);
var
vBody: RawJSON;
res: array [0..0] of TValuePUTF8Char;
sParam: RawUTF8;
begin
if Ctxt.Method = mPOST then begin
vBody := Ctxt.Call.InBody;
JSONDecode(vBody, ['Param1'], @res, true);
sParam := res[0].Value;
end;
Ctxt.Results(['Test: ' + sParam]);
end;
This is what you meant?
Last edited by tomek (2020-04-01 15:27:28)
Offline
Pages: 1