Last active
June 17, 2017 18:18
-
-
Save eufelipe/594ac2dca90a02cd9ca09f05e18a2d19 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
import com.squareup.okhttp.Callback; | |
import com.squareup.okhttp.MultipartBuilder; | |
import com.squareup.okhttp.OkHttpClient; | |
import com.squareup.okhttp.Request; | |
import com.squareup.okhttp.RequestBody; | |
import com.squareup.okhttp.Response; | |
*/ | |
OkHttpClient client = new OkHttpClient(); | |
RequestBody requestBody = new MultipartBuilder() | |
.type(MultipartBuilder.FORM) | |
.addFormDataPart("key", "value") | |
.build(); | |
Request request = new Request.Builder() | |
.url("http://www..") | |
.post(requestBody) | |
.build(); | |
try { | |
Response response = client.newCall(request).execute(); | |
String responseString = response.body().string(); | |
response.body().close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment