@Test public void call() throws IOException { JSONObject jsonObject = new JSONObject(); jsonObject.put("msg", "hello"); jsonObject.put("userId", 1586617710861L); HttpClient.call(okHttpClient,jsonObject.toString(),"http: }
public static Response call(OkHttpClient okHttpClient, String params, String url) throws IOException { RequestBody requestBody = RequestBody.create(mediaType, params); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = okHttpClient.newCall(request).execute(); if (!response.isSuccessful()) { throw new IOException("Unexpected code " + response); } return response; }
HttpClient { public static Response call(OkHttpClient okHttpClient, String params, String url) throws IOException { RequestBody requestBody = RequestBody.create(mediaType, params); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = okHttpClient.newCall(request).execute(); if (!response.isSuccessful()) { throw new IOException("Unexpected code " + response); } return response; } }
HttpClient { public static Response call(OkHttpClient okHttpClient, String params, String url) throws IOException { RequestBody requestBody = RequestBody.create(mediaType, params); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = okHttpClient.newCall(request).execute(); if (!response.isSuccessful()) { throw new IOException("Unexpected code " + response); } return response; }  }
HttpClient { public static Response call(OkHttpClient okHttpClient, String params, String url) throws IOException { RequestBody requestBody = RequestBody.create(mediaType, params); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = okHttpClient.newCall(request).execute(); if (!response.isSuccessful()) { throw new IOException("Unexpected code " + response); } return response; }  static Response call(OkHttpClient okHttpClient, String params, String url); }
HttpClient { public static Response call(OkHttpClient okHttpClient, String params, String url) throws IOException { RequestBody requestBody = RequestBody.create(mediaType, params); Request request = new Request.Builder() .url(url) .post(requestBody) .build(); Response response = okHttpClient.newCall(request).execute(); if (!response.isSuccessful()) { throw new IOException("Unexpected code " + response); } return response; }  static Response call(OkHttpClient okHttpClient, String params, String url);  }