0

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?

TomahawkPhant
  • 1,130
  • 4
  • 15
  • 33
  • debug the contents of resource.getResponse(). I'm guessing the authentication is wrong or similar. – tom Dec 16 '13 at 14:00

1 Answers1

2

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

Thierry Templier
  • 198,364
  • 44
  • 396
  • 360