OkHttp3设置Content-Type
来源:互联网 发布:pg数据库是什么 编辑:程序博客网 时间:2024/05/16 07:57
private void connectToApi(String requestMsg, String bizCode) throws IOException { try { OkHttpClient okHttpClient = this.createClient(); Logger.t("request").d(url.toString()); /** * 创建请求的参数body */ RequestBody body = FormBody.create(MediaType.parse("application/json"), requestMsg); Request request = new Request.Builder() .url(url) .post(body) .build(); Response response = okHttpClient.newCall(request).execute(); if (response.isSuccessful()) { this.response = response.body().string(); } else { throw new IOException("无法连接到服务器,请检查网络连接"); //throw new IOException("Unexpected code " + response); } } catch (IOException e) { e.printStackTrace(); throw new IOException("网络有点卡..."); } }
阅读全文
0 0
- OkHttp3设置Content-Type
- OkHttp3设置Content-Type
- 设置content type
- Okhttp3问题 Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
- 关于AFNetworking设置Content-Type,请求头
- 关于OkHttp设置Content-Type问题
- springmvc 设置content-type为 application/json
- JSP内置对象:设置content-type属性
- content-type
- Content Type
- content-type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- Content-Type
- content type
- React-Native子组件修改父组件的几种方式,兄弟组件状态修改
- HTML <form> 标签的 method 属性
- 操作系统的特征
- Java的事务处理
- leetcode 120
- OkHttp3设置Content-Type
- 深入揭发:Android 的声音延迟
- PHP获取当前脚本内存占用情况
- 快速搭建HTTP服务器 go http server
- JavaScript(一)--变量和数据类型/流程控制语句/函数/网页时钟/基于对象编程
- RecyclerView实现对话框时键盘遮住对话内容问题.md
- js编写带阴历的日历
- 操作系统的目标和功能
- 4.3 初识Android Studio中的Gradle