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);
So in der Schnittstelle von Retrofit (params ist von der Art, "username = david & password = test123 & scope = openid + E-Mail")Wie übergebe ich rohe Zeichenkette des Inhaltstyps x-www-form-urlencoded in Retrofit?
@POST("core/connect/userinfo")
Call<ResponseBody> getLogin(@Body String params);
Dies ist nicht der richtige Weg. Die oben genannte Methode funktioniert nicht. –
können Sie die offizielle Dokumentation beziehen - http://square.github.io/retrofit/2.x/retrofit/ – SaravInfern