Delphi DataAbstract and REST

Years ago, I asked about REST and DataAbstact. At that time, there was only the .Net example.

Is there now an example of Delphi DataAbstract with REST? Or an example of Delphi RO using REST with database tables?

I have a particular use case that I would like to test this week with our IOS Swift app using JSON.

Thanks.
Bill Brittain

Hi,

We have several things that you can use:

Evgeny,

I was looking at the page Adding HttpAPI to a Server (Delphi) in the documentation but do you have an example anywhere with RO returning a data in a service which is using the SqLite database to pull data from a table using REST. That would be something pretty straightforward.

Just need a quick example. I am only needing to pull from a couple of tables and update their data so this should be very simple.

Thanks.
Bill Brittain

Hi,

You can adjust Arrays sample (Delphi) and add HttpApi attributes to server:

after adding

[ROHttpAPIMethod('GetTables', 'GET')]

and dropping TROHttpApiDispatcher to main form and linking it with server you can get in browser for http://localhost:8099/api/GetTables something like

{“aCustomers”:[{“Address”:“Obere Str. 57”,“City”:“Berlin”,“CompanyName”:“Alfreds Futterkiste”,“ContactName”:“Maria Anders”,“ContactTitle”:“Sales Representative”,“Country”:“Germany”,“CustomerID”:“ALFKI”,“Fax”:“030-0076545”,“Phone”:“030-0074321”,“Postalcode”:“12209”,“Region”:“”},{“Address”:“Avda. de la Constituci\u0413\u0456n 2222”,“City”:“M\u0413\u00A9xico D.F.”,“CompanyName”:“Ana Trujillo Emparedados y helados”,“ContactName”:“Ana Trujillo”,“ContactTitle”:“Owner”,“Country”:“Mexico”,“CustomerID”:“ANATR”,“Fax”:“(5) 555-3745”,“Phone”:“(5) 555-4729”,“Postalcode”:“05021”,“Region”:“”},{“Address”:“Mataderos 2312”,“City”:“M\u0413\u00A9xico D.F.”,“CompanyName”:“Antonio Moreno Taquer\u0413\u00ADa”,“ContactName”:"Antonio …

Well, I spent a couple of hours these past two days and have had no luck in producing a very simple REST server. Funny thing is, I am able to connect to my data in the server with absolutely no problem.

The problem I am having is the HttpApiDispatcher is not showing the “paths” for any of the HttpApiMethods. I have read the " Adding HttpAPI to a Server (Delphi)" over and over again. Tried to modify the Arrays sample with the instructions above. And created a completely new Code First server and put the sample methods in just like the docs page. No luck. Path not found. What the heck am I doing wrong here?

Where is a fully compilable Code First REST example that I can take a look at? No RODL to get in the way. There is no code examples in the Samples folder that I can find.

I need to determine if this is possible or go get something else. Heck, I did one with PHP in about an hour.

Thanks.
Bill Brittain

This is the result I am getting.

I have this on the datamodule. With the dispatcher assigned to the ROServer.

And this is the Service Library. Only one method. Really simple. But it does not show the path for the method in the output. Gotta be something simple that I am missing.

Hi,

what exactly version of Remoting SDK are you using?
You can see it in ROVersion.inc

We have HttpApiAuthentication sample that demonstrates usage of HttpAPI

note: CodeFirst version of sample still uses [ROCustom(HttpAPITag, value) instead of new [ROHttpAPI*] attributes.

check more about this at https://talk.remobjects.com/t/remoting-sdk-for-delphi-vnext-new-features/18354/67