Product Documentation

FairCom Edge Android IoT

Previous Topic

Next Topic

Using REST with curl

An alternative method to use REST is with the command line tool curl. If you intend to use curl to process your json files to communicate with the FairCom EDGE Server, you may create your json files to define your table, index and records, as described in our documentation:

https://docs.faircom.com/doc/rest_api/

And once these files are created, you may issue commands like:

test with http://localhost:8080/ctree/api/v1/openapi - notice the port change here

create table, index, insert records and query -

https://docs.faircom.com/doc/rest_api/

created 4 json files (create_table.json, create_index.json, create_records.json, and query_records.json) and run the following commands:

To list your databases, issue:

curl -u admin:ADMIN' http://localhost:8080/ctree/api/v1/database/

To create a new databases named FairComEdgeDB, issue:

curl -u admin:ADMIN -d '' http://localhost:8080/ctree/api/v1/database/FairComEdgeDB

To create a table named books, whose fields are defined in the file create_table.json locally where do you issue the command:

curl -u admin:ADMIN -d @create_table.json http://localhost:8080/ctree/api/v1/table/ctreeSQL/books

To add one index, defined in the create_inde.json file, issue:

curl -u admin:ADMIN -d @create_index.json http://localhost:8080/ctree/api/v1/index/ctreeSQL/books/c_index

To add records, you may issue:

curl -u admin:ADMIN -d @create_records.json http://localhost:8080/ctree/api/v1/record/ctreeSQL/books

where create_records.json is a file with your records.

To visualize your data, you may issue either

curl -u admin:ADMIN http://localhost:8080/ctree/api/v1/record/ctreeSQL/books/1

or

curl -u admin:ADMIN -d @query_records.json http://localhost:8080/ctree/api/v1/query/ctreeSQL/books/c_index?top=100

All the details on the JSON format for the used files is provided in https://docs.faircom.com/doc/rest_api/.

TOCIndex