How to make OKHTTP post request without a request body?

Justcurious picture Justcurious · Mar 2, 2016 · Viewed 19.7k times · Source

Possible way to make OkHTTP post request without a request body in okhttp library ?

Answer

Justcurious picture Justcurious · Mar 2, 2016
    RequestBody reqbody = RequestBody.create(null, new byte[0]);  
    Request.Builder formBody = new Request.Builder().url(url).method("POST",reqbody).header("Content-Length", "0");
    clientOk.newCall(formBody.build()).enqueue(OkHttpCallBack());