Retrofit 2.0-beta-2 is adding literal quotes to MultiPart values

This is because it’s running through the JSON converter. Solution1: use RequestBody instead of String public interface ApiInterface { @Multipart @POST(“user/login/”) Call<SessionToken> userLogin(@Part(“username”) RequestBody username, @Part(“password”) RequestBody password); } Build RequestBody: RequestBody usernameBody = RequestBody.create(MediaType.parse(“text/plain”), usernameStr); RequestBody passwordBody = RequestBody.create(MediaType.parse(“text/plain”), passwordStr); Launch network operation: retrofit.create(ApiInterface.class).userLogin(usernameBody , passwordBody).enqueue()…. Solution2: Create a custom ConverterFactory to dispose String … Read more

POST Multipart Form Data using Retrofit 2.0 including image

There is a correct way of uploading a file with its name with Retrofit 2, without any hack: Define API interface: @Multipart @POST(“uploadAttachment”) Call<MyResponse> uploadAttachment(@Part MultipartBody.Part filePart); // You can add other parameters too Upload file like this: File file = // initialize file here MultipartBody.Part filePart = MultipartBody.Part.createFormData(“file”, file.getName(), RequestBody.create(MediaType.parse(“image/*”), file)); Call<MyResponse> call = … Read more

How do you connect localhost in the Android emulator? [duplicate]

Use 10.0.2.2 to access your actual machine. As you’ve learned, when you use the emulator, localhost (127.0.0.1) refers to the device’s own loopback service, not the one on your machine as you may expect. You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development.

Make an HTTP request with android

UPDATE This is a very old answer. I definitely won’t recommend Apache’s client anymore. Instead use either: Retrofit OkHttp Volley HttpUrlConnection Original Answer First of all, request a permission to access network, add following to your manifest: <uses-permission android:name=”android.permission.INTERNET” /> Then the easiest way is to use Apache http client bundled with Android: HttpClient httpclient … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)