Simple REST client in Java for IBM Watson

As you know Maximo is currently based on a Java legacy infrastructure as long as IBM Watson is based on a cloud infrastructure with REST APIs. Here my proof of concept to invoke Watson by Control Desk.

To address my requirement without use the current and cool JavaScript frameworks I developed a simple REST client in Java plus a bunch of jar libraries. I hoping that it will help someone in some way.

To invoke the IBM Watson REST APIs regarding the Retrieve and Rank service:

IBM Watson REST APIs - Retrieve and rank service
IBM Watson REST APIs – Retrieve and rank service

I developed the following Simple REST client in Java

Some details:

  • Invoking the search Solr standard query api
  • Using the following Jars: httpclient-4.5.1.jar , httpcore-4.4.3.jar ,  commons-logging-1.2.jar , commons-codec-1.9.jar , java-json.jar
  • Using the JSONObject to handling the HTTP response with JSON content


Here the output from my simple REST client in Java for IBM Watson

Output - REST API IBM Watson
Output – REST API IBM Watson

Your comments and suggestions are welcome.


Show More

Mario Noioso

IBMer, engineer, technology enthusiast, inventor, coder, gamer, Linux lover, bassist wannabe, TBD. Nerd since 80s.

Related Articles


  1. Hi Mario,
    I`m doing an application using retrieve and rank and now I need to save a json in the cluster, I tried to use this code

    String url = “”;
    HttpPost request = new HttpPost(url);
    StringEntity params =new StringEntity(“details={\”id\”:\”7777777777\”,\”body\”:\”bla12345\”} “);
    request.addHeader(“content-type”, “application/json”);

    HttpResponse response = httpClient.execute(request);
    I receive the result
    HTTP/1.1 200 OK [Date: Wed, 28 Jun 2017 21:19:16 GMT, Server: Apache, Content-Length: 595, Connection: close, Content-Type: text/html;charset=ISO-8859-1] org.apache.http.conn.BasicManagedEntity@58a90037

    But it was not persisted.
    Do you have any ideas? I tried to find an example that persist data in cluster using R&R and found nothing.
    Thanks a lot in advance
    Best Regards

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

HTML Snippets Powered By :