Retrofit 2 with only form-data

Here’s another Solution using request body:

RequestBody requestBody = new MultipartBody.Builder()
        .setType(MultipartBody.FORM)
        .addFormDataPart("param1", param1)
        .addFormDataPart("param2", param2)
        .build();

apiInterface.somePostMethod(requestBody).enqueue(
    //onResponse onFailure methods
);

here’s my api inteface POST method

@POST("somePostMethod")
Call<ResponseBody> somePostMethod(@Body RequestBody body);

Hope it helps.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)