CustomStringRequest customStringRequest = new CustomStringRequest(requestMethod.ordinal(), serverUrl,
result -> {
Log.d(TAG, "headers: " + result.headers);
Log.d(TAG, "response: " + result.response);
createTaskItem(result);
},
error -> {
Log.d(TAG, "error: " + error);
})
错误在JSON
字符串中,我试图得到这样的错误:
new String(error.networkResponse.data, "utf-8");
new String(error.networkResponse.data);
以上方法均无效,我总是得到空字符串,不知道为什么:(
您可以在图片中看到字节,错误响应实际上是这个:
{
"error": [
"Wrong Credentials!"
],
"email_exists": false
}
我正在使用:
implementation 'com.android.volley:volley:1.1.1'
您可以使用GSON将您的响应转换为json对象,
val customPojo = CustomPojo()
val gson = Gson()
gson.toJson(myPojo)
CustomPojo应该是您的响应模型类。