Skip to content

Instantly share code, notes, and snippets.

@edwin-develop
Last active March 12, 2022 22:44
Show Gist options
  • Select an option

  • Save edwin-develop/493cd1e2b8597f02c75e8a8a510e7ccb to your computer and use it in GitHub Desktop.

Select an option

Save edwin-develop/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;
}
}
@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