Reputation: 866
I would like to send a get
request to a remote server using Restlet
and receive the response (as Json
).
Here is my starting point, please feel free to complete:
ClientResource cr = new ClientResource("https://"+url);
JsonRepresentation r = (JsonRepresentation) cr.get();
r.getJsonObject().get("MY_VALUE");
Restlet version 2.1.7
Json: {"title":"General Terms & Conditions","version":"20022014_001"}
Upvotes: 0
Views: 971
Reputation: 202276
In fact, you don't use the JsonRepresentation
the right way. The method get
of the class ClientResource
doesn't return an element of such type. You must use it as described below:
ClientResource cr = new ClientResource("https://"+url);
Representation repr = cr.get();
JsonRepresentation jsonRepr = new JsonRepresentation(repr);
String value = jsonRepr.getJsonObject().get("MY_VALUE");
Hope it helps you, Thierry
Upvotes: 1