;一、問題點在於 下圖紅框裏寫成 text/html了,須要改爲application/json,形成的問題有:unexpected end of stream 這個是406錯誤;加上日誌以後okhttp好用了:html
日誌:json
.addInterceptor(new Interceptor() { @Override public Response intercept(Chain paramAnonymousChain) throws IOException { return paramAnonymousChain.proceed(paramAnonymousChain.request().newBuilder() //.addHeader("Connection", "close") .addHeader("Accept", "Application/Json") // .addHeader("token", SharedPreferenesUtil.getLoginUserToken(RestSource.this.context) .build()); } }) .addInterceptor(new HttpLoggingInterceptor().//開啓日誌信息 setLevel(HttpLoggingInterceptor.Level.BODY)) .build();