我正在从android向python服务器发送POST请求(OKHttp)。在
public static final MediaType JSON
= MediaType.parse("application/json; charset=utf-8");
String params="name="+Name+"&pass="+Pass;
RequestBody body = RequestBody.create(JSON, params);
Request request=new Request.Builder().url(URL).post(body).build(); //Request{method=POST, url=http://10.XX.XXX.XXX:8080/register, tag=null}
Response res=client.newCall(request).execute();
为什么标签是空的,我是不是在设置POST参数时漏掉了一点?在
参数不是JSON格式。尝试按如下方式构建参数:
如果发生JSONException,还必须使用try/catch。在
相关问题 更多 >
编程相关推荐