-1
     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 interface of retrofit (params is of the type, "username=david&password=test123&scope=openid+email")

  @POST("core/connect/userinfo")
   Call<ResponseBody> getLogin(@Body String params);
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77

1 Answers1

2

you can do like this

@FormUrlEncoded
@POST("core/connect/userinfo")
Call<ResponseBody> getLogin(@Field("username") String username,@Field("password") String password, @Field("scope") String scope);

or use fieldMap annotation

@FormUrlEncoded
@POST("core/connect/userinfo")
Call<ResponseBody> getLogin(@FieldMap(encoded = true) Map<String, String> params);
SaravInfern
  • 3,338
  • 1
  • 20
  • 44