Reputation: 1160
I'm trying to consume a restful web service with Restlet. The service is giving me JSON, so I'm using a JsonRepresentation object to get it, but it's not working. I'm getting a null pointer exception when I call jsonRepresentation.getJsonObject()
.
Here is my code:
ClientResource resource =
new ClientResource("https://api.prosper.com/api/Listings?$top=3");
resource.setChallengeResponse(
ChallengeScheme.HTTP_BASIC,
"username",
"password");
try {
JsonRepresentation jsonRepresentation =
new JsonRepresentation(resource.getResponse().getEntity());
jsonRepresentation.getJsonObject();
} catch (Exception e) { }
Any idea what the issue could be or how I could trouble shoot this?
Upvotes: 0
Views: 1050
Reputation: 202138
I think that you missed the call to the service:
ClientResource resource = (...)
(...)
Representation repr = resource.get();
JsonRepresentation jsonRepresentation = new JsonRepresentation(repr);
JSONObject jsonObj = jsonRepresentation.getJsonObject();
Hope it helps you. Thierry
Upvotes: 2