HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(new OkhttpLogger());
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.connectTimeout(10,TimeUnit.SECONDS)
.addNetworkInterceptor(httpLoggingInterceptor)
.readTimeout(10,TimeUnit.SECONDS)
.build();
// RequestBody headers = RequestBody.create(JSON);
FormBody.Builder requestBody = new FormBody.Builder();
requestBody.add("appproject","1");
Map<String,String> map = new HashMap<>();
map.put("appproject","1");
Request request = new Request.Builder()
.post(RequestBody.create(JSON,new Gson().toJson(map)))
.url(url)
.build();
Call call = okHttpClient.newCall(request);
okhttp添加请求header
猜你喜欢
转载自blog.csdn.net/wangqiuwei07/article/details/83542467
今日推荐
周排行