到requestbody我有這:改造2追加後在截距
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new Interceptor() {
@Override
public com.squareup.okhttp.Response intercept(Chain chain) throws IOException {
Request request = chain.request();
HttpUrl url = request.httpUrl().newBuilder()
.addQueryParameter("platform", "android")
.addQueryParameter("app_version", com.package.BuildConfig.VERSION_NAME)
.build();
Request newRequest = chain.request().newBuilder().url(url).build();
return chain.proceed(newRequest);
}
});
但還要額外交鍵值附加到包含用戶鑰請求主體。這看起來像
RequestBody newBody = RequestBody.create(request.body().contentType(),request.body().content+ request.addPost("sUserKey","3254345kdskf");
...
...
Request newRequest = chain.request()
.newBuilder()
.url(url)
.post(newBody)
.build();
有什麼問題,怎麼做呢? – Blackbelt
在okhttp攔截過程中,您將如何添加額外的POST? –
你想要對不同的端點發布post請求嗎? – Blackbelt