-1

I am trying to make a POST request by ROBOSPICE and I get a NullpointerException:

 public String loadDataFromNetwork() throws Exception {

    return getRestTemplate().getForObject(url, String.class);
}

Here is the exact Error occurring in return line

An exception occurred during request network execution :null

java.lang.NullPointerException

Community
  • 1
  • 1
hoseinit
  • 33
  • 7

1 Answers1

0

Try to surround your request with a try-catch block.

try{
    return getRestTemplate().getForObject(url, String.class);
}catch(RestTemplateException e){
    Log.d("appError", e.getMessage());
}

This error is probably because you're getting a null response. Try verifying first what you're getting as response.