Skip to content

Instantly share code, notes, and snippets.

@CMingTseng
Forked from esantiago1/Send form-data in retrofit
Created September 14, 2018 19:59
Show Gist options
  • Save CMingTseng/683bfb9f9e01e615fde45b1d028898fb to your computer and use it in GitHub Desktop.
Save CMingTseng/683bfb9f9e01e615fde45b1d028898fb to your computer and use it in GitHub Desktop.
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment