0
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request.Builder requestBuilder = chain.request().newBuilder();
requestBuilder.header("Content-Type", "application/x-www-form-urlencoded");
requestBuilder.header("Accept", "text/json");
requestBuilder.header("Authorization","Basic fh73hf78fhhf7at"); }).build();
Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL).client(client).addConverterFactory(GsonConv erterFactory.create()).build();
BetaAPI betaAPI = retrofit.create(BetaAPI.class);
所以在改裝 的接口(params爲類型, 「用戶名=大衛&密碼= test123 &範圍=的OpenID +電子郵件」 的)如何在改造中傳遞內容類型x-www-form-urlencoded的原始字符串?
@POST("core/connect/userinfo")
Call<ResponseBody> getLogin(@Body String params);
這不是做這件事的方法。上述方法不起作用。 –
你可以參考官方文檔 - http://square.github.io/retrofit/2.x/retrofit/ – SaravInfern