Gentics Mesh Java Client


You can add the following maven dependency and repository to your project to get the Gentics Mesh Java client dependencies.

			<name>Gentics Maven Repository</name>

Java REST Client

The REST client can be used to interact with all Gentics Mesh API Endpoints.


MeshRestClient client = MeshRestClient.create("localhost", 8080, false);
client.setLogin("username", "password");

NodeListResponse nodes = client.findNodes("demo", new NodeParametersImpl().setLanguages("en")).blockingGet();
for (NodeResponse nodeResponse : nodes.getData()) {

SSL handling


// Set config settings
Builder builder = MeshRestClientConfig.newConfig();

// Create the client
MeshRestClient client = MeshRestClient.create(;
UserResponse meInfo =;

Methods to set the client key which will be used during SSL handshake:

  • MeshRestClientConfig.Builder#setClientKey(String path)

  • MeshRestClientConfig.Builder#setClientKey(InputStream ins)

  • MeshRestClientConfig.Builder#setClientKey(byte[] data)

Methods to set the client certificate which will be used during SSL handshake:

  • MeshRestClientConfig.Builder#setClientCert(String path)

  • MeshRestClientConfig.Builder#setClientCert(InputStream ins)

  • MeshRestClientConfig.Builder#setClientCert(byte[] data)

Methods to add one or more trusted CAs for the client:

  • MeshRestClientConfig.Builder#addTrustedCA(String path)

  • MeshRestClientConfig.Builder#addTrustedCA(InputStream ins)

  • MeshRestClientConfig.Builder#addTrustedCA(byte[] data)

Method to set the hostname verification checks:

  • MeshRestClientConfig.Builder#setHostnameVerification(boolean flag)

Connection Leaks

In most cases, the connection to Mesh will implicitly be closed when the response object is created. The only exceptions are when loading binary data or doing a webroot or webrootField request (where the response might contain binary data).

For those requests, it is important to make sure, that the response is properly closed in all cases, especially when the response data is not (fully) consumed (e.g. when an error happens while consuming the binary data).

Incorrect example:

client.downloadBinaryField("demo", "01ecd6048ee21471bb90af6deea40d2c", "en", "image")
	.doOnSuccess(response -> {
		// an exception might be thrown here, which would leave the response open

Better example:

client.downloadBinaryField("demo", "01ecd6048ee21471bb90af6deea40d2c", "en", "image")
	.doAfterSuccess(response -> {
		// we explicitly need to close the response here
	.doOnSuccess(response -> {
		// an exception might be thrown here

Example with blocking code:

// try-with-resource will make sure, that close() is called on the response
try (MeshBinaryResponse response = client.downloadBinaryField("demo", "01ecd6048ee21471bb90af6deea40d2c", "en", "image")
	.toSingle().blockingGet()) {
	// an exception might be thrown here

Monitoring Client

The monitoring client can be used to interact with the Monitoring Endpoints.


MonitoringRestClient client = MonitoringRestClient.create("localhost", 8081);

client.status().toSingle().subscribe(status -> {
}, System.err::println);

Use HTTP/2

Since Mesh supports serving over HTTP/2 out of the box, Mesh REST client allows limiting connection protocol to HTTP/2, so instead of time-consuming protocol support check and upgrade the client may use HTTP/2 right away. This is achievable with using Java API MeshRestClientConfig.setProtocolVersion().

Minification and pretty printing the REST payloads

The possibility to either save the amount of payload transferred by the REST requests/responses, or pretty print them for better human readability, is present. By setting the request’s setMinifyJson(boolean) flag one may control the request body minification. Default value is true, so the payloads to send are not human-readable.

NodeListResponse nodes = client.findNodes("demo", new NodeParametersImpl().setLanguages("en")).setMinifyJson(false).blockingGet();

For the control of a response body minification one needs a DisplayParameters#setMinify(boolean) set to the desired request. This parameter override the server-side JSON minification setup per each request. See HTTP Server Options for the server-side configuration.

NodeListResponse nodes = client.findNodes("demo", new NodeParametersImpl().setLanguages("en"), new DisplayParametersImpl().setMinify(false)).blockingGet();