Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 什么属性公开Okhttp响应的消息内容_Java_Android_Okhttp3 - Fatal编程技术网

Java 什么属性公开Okhttp响应的消息内容

Java 什么属性公开Okhttp响应的消息内容,java,android,okhttp3,Java,Android,Okhttp3,我有一个后端,我试图使用okhttp发布一个密码为“12345”的用户注册请求,但失败了 我花了几个小时才发现后端实际上拒绝了所有响应代码为400的数字密码 我发现这个问题的方法是用Python发送相同的post请求,而当我在Python shell中收到问题的详细信息时: >>>request.content b'{"password1":["This password is too short. It must contain at least 8 characters."

我有一个后端,我试图使用okhttp发布一个密码为“12345”的用户注册请求,但失败了

我花了几个小时才发现后端实际上拒绝了所有响应代码为400的数字密码

我发现这个问题的方法是用Python发送相同的post请求,而当我在Python shell中收到问题的详细信息时:

>>>request.content
b'{"password1":["This password is too short. It must contain at least 8 characters.","This password is too common.","This password is entirely numeric."]}'
我想知道如何在android studio中从请求的响应中得到类似的消息,如下所示:

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                if (response.isSuccessful()) {
                    final String jsonResponse = response.body().string();
                    MainActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            m_textView.setText("Successfull!");
                        }
                    });
                } else {

                }
            }
在调试模式下,这个响应有很多属性,但我没有看到任何属性指向python提供的有用内容

谢谢你的建议


谢谢,

看起来以下内容返回了我所需的内容:

response.body().string()

你不是在
response.body()中有它吗?