 <p>Another approach is by using <code>FormBody.Builder()</code>.<br> Here's an example of callback:</p> <pre><code>Callback loginCallback = new Callback() { @Override public void onFailure(Call call, IOException e) { try { Log.i(TAG, "login failed: " + call.execute().code()); } catch (IOException e1) { e1.printStackTrace(); } } @Override public void onResponse(Call call, Response response) throws IOException { // String loginResponseString = response.body().string(); try { JSONObject responseObj = new JSONObject(response.body().string()); Log.i(TAG, "responseObj: " + responseObj); } catch (JSONException e) { e.printStackTrace(); } // Log.i(TAG, "loginResponseString: " + loginResponseString); } }; </code></pre> <p>Then, we create our own body:</p> <pre><code>RequestBody formBody = new FormBody.Builder() .add("username", userName) .add("password", password) .add("customCredential", "") .add("isPersistent", "true") .add("setCookie", "true") .build(); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(this) .build(); Request request = new Request.Builder() .url(loginUrl) .post(formBody) .build(); </code></pre> <p>Finally, we call the server:</p> <pre><code>client.newCall(request).enqueue(loginCallback); </code></pre>