OkHttp bad requestBody

拥有回忆 提交于 2019-12-11 05:17:58

问题


I am using OkHTTP and I have some problems when I try to make a post request.

Here is my code :

client = new OkHttpClient();
formBody = new FormBody.Builder()
                    .add(Constant.DIRECTION, Constant.OUT)
                    .add(Constant.LIMIT, Constant.docs_limit)
                    .add(Constant.IMPORTED, Constant.FALSE)
                    .addEncoded("statuses[]", "4")
request = new Request.Builder()
                        .url(url)
                        .addHeader(Constant.AUTH_TOKEN, sharedPreferences.getString(Constant.TOKEN, ""))
                        .post(formBody)
                        .build();

when I try to send

"statuses[]", "4"

in the debugger it shows that brackets converted to "statuses%5B%5D". How to fix that? Sorry for my poor english.

来源:https://stackoverflow.com/questions/43977865/okhttp-bad-requestbody

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!