Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public interface ApiClientInterface {
@Multipart
@POST("xxxx")
Call<ResponseBody> serviceLogin(@PartMap Map<String, RequestBody> params);
}
..........
ApiClientInterface mApiClientInterface= ApiClient.getInstance().create(ApiClientInterface.class);
RequestBody body = RequestBody.create(MediaType.parse("text/plain"), "value");
Map<String, RequestBody> requestBodyMap = new HashMap<>();
requestBodyMap.put("key", body);
Call<ResponseBody> response=mApiClientInterface.serviceLogin(requestBodyMap);
userRCall.enqueue(................);
public class ApiClient {
private static final String URL = "";
private static Retrofit mRetrofit = null;
public static Retrofit getInstance() {
if (mRetrofit == null) {
mRetrofit = new Retrofit.Builder()
.baseUrl(URL)
.build();
}
return mRetrofit;
}
}
@alitamoor65

This comment has been minimized.

Copy link

alitamoor65 commented Mar 13, 2019

what is "value" here??

RequestBody.create(MediaType.parse("text/plain"), "value");
@nurhidayat-agung

This comment has been minimized.

Copy link

nurhidayat-agung commented Apr 4, 2019

string that you need to server...
don't forget to use scalar converter in your retrofit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.