OkHttpClient okHttpClient = new OkHttpClient();
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put("city","广州");
paramMap.put("appkey","9878b9b510123e52a951fe2074d19be1");
Request request = new Request.Builder()
.addHeader("content-type", "application/json")
.url("https://way.jd.com/jisuapi/weather")
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"),paramMap.toString()))
.build();
String result = okHttpClient.newCall(request).execute().body().string();
System.out.println(result);
OkHttpClient okHttpClient = new OkHttpClient();
RequestBody requestBody = new FormBody.Builder()
.add("city","广州")
.add("appkey","9878b9b510123e52a951fe2074d19be1")
.build();
Request request = new Request.Builder()
.addHeader("content-type", "application/json")
.url("https://way.jd.com/jisuapi/weather")
.post(requestBody)
.build();
String result = okHttpClient.newCall(request).execute().body().string();
System.out.println(result);