#1 2020-01-09 13:16:39

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

How to pass query with params [HttpApiServer]

Hello,
I would like to pass the select statement with params from the web browser. The backend uses THttpApiServer to serve the json response. The JSONSQLClient demo works fine when I pass the plain query statement without params through the body.

Is this possible to pass for example json with params such as:

{

"query":"select * from users where name=? and id > ?",
"params":["john","6"]

}

Offline

#2 2020-01-09 20:13:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,672
Website

Re: How to pass query with params [HttpApiServer]

No, it is not.
You would need to adjust the sample code.
But I would warn against such remote execution of arbitrary SQL, for several reasons: mostly architecture (switch to n-Tier) and security (executing any kind of select is unsafe).

I suspect you are reinventing the wheel.
Check https://synopse.info/files/html/Synopse … l#TITL_131

Offline

#3 2020-01-10 09:07:53

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Re: How to pass query with params [HttpApiServer]

8.2.6. Remote access via HTTP

"The transmission protocol uses an optimized binary format..." , how can I send query from web browser and retrieve results? I suppose the SynDBRemote is a solution for pure delphi client-server apps.

Offline

#4 2020-01-10 09:33:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,672
Website

Re: How to pass query with params [HttpApiServer]

Yes, SynDBRemote is for Delphi/FPC clients.

For the browser, there is no built-in solution, since it is weak in architecture, and unsafe.
You can adjust/expand the sample code, if you really want it. But we won't put it in the framework official code - as a 3rd party sample perhaps.

Offline

Board footer

Powered by FluxBB