Skip to content

Instantly share code, notes, and snippets.

@eufelipe
Last active June 17, 2017 18:18
Show Gist options
  • Save eufelipe/594ac2dca90a02cd9ca09f05e18a2d19 to your computer and use it in GitHub Desktop.
Save eufelipe/594ac2dca90a02cd9ca09f05e18a2d19 to your computer and use it in GitHub Desktop.
/*
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