Forked from esantiago1/Send form-data in retrofit
Created
September 14, 2018 19:59
-
-
Save CMingTseng/683bfb9f9e01e615fde45b1d028898fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(................); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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