Skip to content

Instantly share code, notes, and snippets.

@bucker
Last active September 7, 2019 13:00
Show Gist options
  • Save bucker/67aced5bdf23c89eec58 to your computer and use it in GitHub Desktop.
Save bucker/67aced5bdf23c89eec58 to your computer and use it in GitHub Desktop.
OkHttp recipe for dummy

OkHttp recipe

  • Using POST
OkHttpClient client = new OkHttpClient();
String url = "http://youserver.com";
RequestBody body = new FormEncodingBuilder()
    .add("id", id)
    .add("idx", idx)
    .build();
Request request = new Request.Builder()
    .url(url)
    .post(body)
    .addHeader("token", token)
    .build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment