Okhttp3 - RequestBody.create(contentType, content) Deprecated
我没有找到任何如何替换弃用方法的示例。okhttp3 主页上的示例是旧的。这是其中之一:
public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
OkHttpClient client = new OkHttpClient();
String post(String url, String json) throws IOException {
    RequestBody body = RequestBody.create(JSON, json);
      Request request = new Request.Builder()
          .url(url)
          .post(body)
          .build();
  try (Response response = client.newCall(request).execute()) {
    return response.body().string();
  }
}
如果有人能解决这个问题,我将不胜感激。
更新:我正在使用'com.squareup.okhttp3:okhttp:4.0.1'
 
					 
				 
				    		 
				    		 
				    		