You are not logged in.
Hi,
I'm studying mORMot to use REST in a project that will be consumed by an application APS NET.
Well, I have the method FindProduto and want to spend as a JSON POST parameter eg http://localhost:777/Produtos/FindProduto/{"codigo": 123456}
Is possible capture the JSON in method FindProduto with parameter aParam?
My code
function TServiceProdutos.FindProduto(
var aParams: TSQLRestServerCallBackParams): Integer;
begin
// I need cature JSON informed in parameter URI
Result:= HTML_SUCCESS;
end;
Inicialization of my service
constructor TJSONServer.Create;
begin
ModelProdutos:= TSQLModel.Create([], 'Produtos');
ServiceProdutos:= TServiceProdutos.Create(ModelProdutos);
ServiceProdutos.ServicesRouting:= rmJSON_RPC;
Server := TSQLite3HttpServer.Create('9000', [ ServiceProdutos ] );
end;
How is it possible to define the type of mORMot the HTTP method (POST, GET, DELETE, PUT) that will run on a service method?
I need to use POST in the function FindProduto but I works only with GET (http://localhost:777/Produtos/FindProduto?codigo=123456)
Thanks
Offline
You are mixing method-based services (method name with TSQLRestServerCallBackParams parameter) and interface-based services (ServicesRouting:= rmJSON_RPC).
Take a look at the SAD pdf, in it latest 1.18 revision (see "Downloads" link above), about method-based services, and you will find exhaustive information, and code sample.
It will certainly help making things clearer.
You have the method execution verb in the TSQLRestServerCallBackParams.Verb
In the current implementation, method-based services did only process GET and PUT verbs, at ModelRoot/MethodName and ModelRoot/TableName/ID/MethodName URIs.
I've fixed this: now TSQLRestServer.URI() will handle POST/PUT/DELETE ModelRoot/MethodName as method-based services.
See http://synopse.info/fossil/info/e3273c5ce8
So you will be able to receive all HTTP methods at the service level.
Offline