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);
donc dans l'interface de mise à niveau (params est du type "nom d'utilisateur = david & password = test123 & scope = Openid + email")Comment passer la chaîne brute du type de contenu x-www-form-urlencoded en retrofit?
@POST("core/connect/userinfo")
Call<ResponseBody> getLogin(@Body String params);
Ce n'est pas la façon de le faire. La méthode mentionnée ci-dessus ne fonctionne pas. –
vous pouvez vous référer à la documentation officielle - http://square.github.io/retrofit/2.x/retrofit/ – SaravInfern