okhttp使用方式有错误,body().toString()修改为body().string()
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user