越来越坏请求,当我在POST方法请求体中发送 “/” 字符获取HTTP/1.1 400错误的请求[ R] [ n]的
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(kairosDBUrl);
RequestEntity requestEntity = null;
try {
requestEntity = new StringRequestEntity(inputBody, "text/json", "UTF-8");
postMethod.setRequestEntity(requestEntity);
client.executeMethod(postMethod);
responseBody = IOUtils.toString(postMethod.getResponseBodyAsStream(), postMethod.getResponseCharSet());
} catch (IOException e) {
LOG.error("Unexpected exception : {}", e);
} finally{
postMethod.releaseConnection();
}
输入:
{metrics=[{name=apache.Activity_Bytes/req, tags={host=[ip-10-0-0-201]}, aggregators=[{name=avg, align_sampling=true, sampling={value=5, unit=seconds}}]}], cache_time=0, start_absolute=1496222264000, end_absolute=1496224064000}
错误:
"{"errors":["com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 39"]}"
这只是一个疯狂的猜测,但你是否试图通过反斜杠斜线逃避斜线? – Jonathan
你的JSON无效,你应该纠正它。 – Dorian
JSON是完整的垃圾 - 抱歉。尝试http://json-validator.com/来更正您的输入。 –