1
0
mirror of synced 2025-12-28 14:07:58 +08:00

okhttp使用方式有错误,body().toString()修改为body().string()

This commit is contained in:
ecoolper
2017-05-04 11:02:24 +08:00
parent 6b7c86da95
commit 59fc9134c8
12 changed files with 17 additions and 12 deletions

View File

@@ -213,7 +213,7 @@ public class MediaDownloadRequestExecutor extends AbstractRequestExecutor<File,
String contentType = response.header("Content-Type");
if (contentType != null && contentType.startsWith("application/json")) {
// application/json; encoding=utf-8 下载媒体文件出错
throw new WxErrorException(WxError.fromJson(response.body().toString()));
throw new WxErrorException(WxError.fromJson(response.body().string()));
}
String fileName = getFileName(response);

View File

@@ -136,7 +136,7 @@ public class MediaUploadRequestExecutor extends AbstractRequestExecutor<WxMediaU
Request request = new Request.Builder().url(uri).post(body).build();
Response response = client.newCall(request).execute();
String responseContent = response.body().toString();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);

View File

@@ -141,7 +141,7 @@ public class SimpleGetRequestExecutor extends AbstractRequestExecutor<String, St
Request request = new Request.Builder().url(uri).build();
Response response = client.newCall(request).execute();
String responseContent = response.body().toString();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);

View File

@@ -156,7 +156,7 @@ public class SimplePostRequestExecutor extends AbstractRequestExecutor<String, S
Request request = new Request.Builder().url(uri).post(body).build();
Response response = client.newCall(request).execute();
String responseContent = response.body().toString();
String responseContent = response.body().string();
WxError error = WxError.fromJson(responseContent);
if (error.getErrorCode() != 0) {
throw new WxErrorException(error);