How to use OKHTTP to make a post request?

后端 未结 13 1069
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 05:06

I read some examples which are posting jsons to the server.

some one says :

OkHttp is an implementation of the HttpUrlConnection interface p

13条回答
  •  一个人的身影
    2020-12-02 05:44

    You need to encode it yourself by escaping strings with URLEncoder and joining them with "=" and "&". Or you can use FormEncoder from Mimecraft which gives you a handy builder.

    FormEncoding fe = new FormEncoding.Builder()
        .add("name", "Lorem Ipsum")
        .add("occupation", "Filler Text")
        .build();
    

提交回复
热议问题