How to add default params by using Retrofit and OKHttp in every post
<p>I'm just learning Retrofit and OKHttp, now I have an issue.
Every request in my app is POST, just like this:</p>

<pre><code>@FormUrlEncoded
@POST("some url")
Observable&lt;Result&gt; getData(@Field("id") String id);
</code></pre>

<p>In every POST, there are two same params. So in a most simple way, I can add two more @Field in every method, for example, @Field("token"),@Field("account"). But I think there must be a smart way.</p>

<p>Then I thought OkHttpClient may solve this.</p>

<pre><code>OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request request = chain.request();
            RequestBody body = new FormBody.Builder().add("account", "me")
                    .add("token", "123456").build();
            request = request.newBuilder().post(body).build();
            return chain.proceed(request);
        }
    }).build();
Retrofit retrofit = new Retrofit.Builder()
            .baseUrl("some base url")
            .client(client)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .build();
</code></pre>

<p>Or</p>

<pre><code>HttpUrl url = request.url().newBuilder()
                    .setEncodedQueryParameter("account", "me")
                    .setEncodedQueryParameter("token", "123456")
                    .build();
</code></pre>

<p>The first method just replace all Field to these two.</p>

<p>The second method just add these two as GET parameters, not POST.</p>

<p>Now I have absolutely no idea how to make this work.</p>