Why doesn’t find response.getBody().in()) , do I have everything right? please check. The task is to send to the POST server a request with a login and password.

 import retrofit.RestAdapter; import retrofit2.*; import retrofit2.http.*; public interface API { @FormUrlEncoded @POST("/reg.php") Response saveUserInfo(@Field("login") String userName, @Field("password") String userPass); } RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("http://mysite.ru/auth/login") .build(); API api = restAdapter.create(API.class); @Override public void success(Response response) { // Try to get response body BufferedReader reader = null; StringBuilder sb = new StringBuilder(); try { reader = new BufferedReader( new InputStreamReader(response.getBody().in())); String line; try { while ((line = reader.readLine()) != null) { sb.append(line); } } catch (IOException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } String result = sb.toString(); } 
  • What do you need to get from the Response? It can immediately create a model that will be returned by the saveUserInfo method. Something like this: MyModel saveUserInfo (...) - temq
  • I need to get a response from the server that the authorization has passed and with the access_token received in it. - Slava Nenashev February
  • The answer from the server in what form comes? Json? - temq
  • The answer comes in json format - Slava Nenashev

0