Skip to content

Simple Java interface to access HTTP API of c8db (Macrometa)

Notifications You must be signed in to change notification settings

MaheshMadushan/c8db-http-java-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 

Repository files navigation

Macrometa C8DB HTTP Access

This is a simple java interface for accessing HTTP API of c8db in macrometa GDN.

Usage/Examples

Create C8DB object with host name, port and API key. This will create a connection to the database. (jwt and pw authentication will support in future release)

C8DB db = new C8DB.Builder()
                .hostName("www.example.com")
                .port(443)
                .apiKey("apikey-xxxxxxxxx")
                .build();

Then create a HTTPEndPoint as follows and add HTTPEndpoint to the HTTPRequest with specifying request method as follows.

HTTPEndPoint endPoint = new HTTPEndPoint("/_api/key/AccessPortal/database?full=true");

HTTPRequest request = new HTTPRequest.Builder()
                .RequestType(HTTPMethod.GET)
                .EndPoint(endPoint)
                .build();

Then execute request against C8DB object that is created. This will return a response body of type VPackSlice.

VPackSlice responseBody = db.execute(request);

To access values in json use VPackSlice API as follows.

int intValueInJSONObject = responseBody.get("field-name-in-json-response").getAsInt();

About

Simple Java interface to access HTTP API of c8db (Macrometa)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages