Skip to content

Instantly share code, notes, and snippets.

@esantiago1
Last active March 12, 2022 22:44
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save esantiago1/493cd1e2b8597f02c75e8a8a510e7ccb to your computer and use it in GitHub Desktop.
Save esantiago1/493cd1e2b8597f02c75e8a8a510e7ccb 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;
}
}
@alitamoor65
Copy link

what is "value" here??

RequestBody.create(MediaType.parse("text/plain"), "value");

@nurhidayat-agung
Copy link

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