|
接口代码: @RequestMapping("/sendHttps")
public void sendHttps() throws ParseException {
Map<String,String> map=new HashMap<>();
map.put("page","1");
map.put("pageSize","10");
Map<String,Object> map1=new HashMap<>();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str="2022-09-02 12:00:00";
Date startTime=sdf.parse(str);
Long beginTime=startTime.getTime();
Long endTime=System.currentTimeMillis();
map1.put("beginTime",beginTime);
map1.put("endTime",endTime);
map1.put("puID","UA_2644F61C");
map.put("filter",map1.toString());
doPost("https://localhost:9781/bvcsp/v1/pu/recordfile/filter/:UA_2644F61C",map,"utf8");
}
public String doPost(String url, Map<String, String> map, String charset) {
HttpClient httpClient = null;
HttpPost httpPost = null;
String result = null;
try {
httpClient = new SSLClient();
httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type","application/json");
httpPost.setHeader("Authorization","Y3UrQ1VfYWRtaW4rYWRtaW4rMjYrMjc4NTExKzE2NjIzMzg2NTcrYnZodHRwY21kZjgwNzRmZGMzZTI4YzE4YQ");
//设置参数
List<NameValuePair> list = new ArrayList<NameValuePair>();
Iterator iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) iterator.next();
list.add(new BasicNameValuePair(elem.getKey(), elem.getValue()));
}
if (list.size() > 0) {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, charset);
httpPost.setEntity(entity);
}
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println(result);
return result;
}
报错信息: {"code":4,"msg":"invalid character 'i' in literal false (expecting 'a')"} |
|