Hello, I am learning to use Retrofit . I use AIDE, in jarnik. It is necessary to get a response from the server without passing the parameters to it.
Created a class
public class App63 extends Application { private static Api63 api63; private Retrofit retrofit; @Override public void onCreate() { super.onCreate(); retrofit = new Retrofit.Builder().baseUrl("http://www.chat.pareto-marketing.ru/").addConverterFactory(GsonConverterFactory.create()).build(); api63 = retrofit.create(Api63.class); } public static Api63 getApi() { return api63; } } Interface
public interface Api63 { @GET("getform") Call<ResponseBody> getData(); } A piece of activity code
Call<ResponseBody> list = App63.getApi().getData(); list.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> p1, Response<ResponseBody> p2) { try { Log.d("$", p2.body().string()); } catch (IOException e) {} } @Override public void onFailure(Call<ResponseBody> p1, Throwable p2) { // TODO: Implement this method } }); } } The resolution in the manifest is. Android 6.0.1
I receive, His Majesty, NPE:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String okhttp3.ResponseBody.string()' on a null object reference The latest versions of Liby, unite everything into one jar. body.code() returns 404 , body.message() returns Not Found .
http://www.chat.pareto-marketing.ru/getform/you have json and is not given - rjhdby