String提交POST
2018-12-27 20:50 更新
所谓String提交POST,就是将一段字符串直接扔进Request请求中,字符串一般都是有格式约定的,比如是xml、json或其他等。
比如像微信开放平台(https://mp.weixin.qq.com/)的接口,所有数据提交方式就是这种。
String responseData = HttpClient
.textBody("http://localhost:8080/okhttp-server-test/userInfo/create")
// 请求方式和请求url
.json("{\"username\":\"mzlion\",\"userPwd\":\"123\"}")
// post提交json
//.xml("<?xml version=\"1.0\" encoding=\"utf-8\" ?>")
//post提交xml
//.html("function fun(){}")
//post提交html
//.charset("utf-8")
//设置编码
.execute()
.asString();以上内容是否对您有帮助:

免费 AI IDE


更多建议: