问题描述
"error":{"detail":"拒绝了内容长度 = 13011091 字节的大型 REST 负载。最大允许:10485760 字节。","message":"读取请求时出现异常"},"status":"失败"}
代码如下:
JSONObject AttachmentData = new JSONObject();
AttachmentData.put("agent",this.getAgent());
AttachmentData.put("topic",this.getTopic());
AttachmentData.put("name",this.getName());
AttachmentData.put("source",this.getSource());
AttachmentData.put("payload",this.getPayload());
try {
AuthenticationSNowInfo auth = new AuthenticationSNowInfo(sysDomain);
String UserId = auth.getUserId();
String Password = auth.getpassword();
if (this.webServiceAddress != null && !this.webServiceAddress.equalsIgnoreCase("")) {
logger.debug("Calling webservice: " + this.webServiceAddress);
sNowLogger.debug("Calling webservice: " + this.webServiceAddress);
url = new URL(this.webServiceAddress);
conn = (HttpURLConnection) url.openConnection();
String encoded = java.util.Base64.getEncoder()
.encodetoString((UserId + ":" + Password).getBytes(StandardCharsets.UTF_8));
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization","Basic " + encoded);
conn.setRequestProperty("Content-Type","application/json");
conn.setRequestProperty("Accept","application/json");
OutputStream os = conn.getoutputStream();
os.write(AttachmentData.toString().getBytes(StandardCharsets.UTF_8));
os.flush();
BufferedReader br;
logger.debug(conn.getResponseCode());
if (conn.getResponseCode() > 199 && conn.getResponseCode() < 300) {
br = new BufferedReader(new InputStreamReader((conn.getInputStream()),StandardCharsets.UTF_8));
} else {
br = new BufferedReader(new InputStreamReader((conn.getErrorStream()),StandardCharsets.UTF_8));
}
returnjsON = br.readLine();
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)