spring boot 发送http 请求问题

//提交审核后给审核人发送邮件提醒信息
JSONObject json=new JSONObject();
json.put("fromAddr",TsConfigHelper.getProperty(EMAILUSER));
Map<String,Object> map=new HashMap<>();
map.put("loginName",nextUser);
Map<String,Object> rmap=tDI9BatchPiccConfigService.findUserByLoginName(map);
json.put("toAddr",rmap.get("EMAIL"));

json.put("ccAddr","");
json.put("uuid","");
json.put("ruleCode","netvalue3NOdiWvQ");
json.put("subject","【国寿I9】减值计量任务提交审核");
json.put("content", String.format("<p>发送时间:" + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()) +"</p><p>请及时处理</p>"));
json.put("sendSatatus","");
json.put("sendTime","");
json.put("retryCount",0);
json.put("status","");
json.put("bcc","");

String reqJsonStr =json.toString();

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.add("Authorization",TsConfigHelper.getProperty(AUTHORIZATION));
HttpEntity<String> entity = new HttpEntity<String>(reqJsonStr,headers);
ResponseEntity<Map> resp = new RestTemplate().exchange(TsConfigHelper.getProperty(HTTPADDR), HttpMethod.POST, entity, Map.class);

// headers.add("Authorization","eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiI2M2U3YjlmMWQ3ZDA0YWVhODdmYjc2NzRlZGY1NmZlNiIsImlkIjoiNjNlN2I5ZjFkN2QwNGFlYTg3ZmI3Njc0ZWRmNTZmZTYiLCJjb2RlIjoiY3JlZGl0LWltcGFpcm1lbnQiLCJuYW1lIjoi5Lit5Zu95Lq65a-_5L-h55So5YeP5YC8IiwiZnR5cGUiOiIxIiwiZXhwIjoxODU1NDQxODU5OTA0MDB9.NzOXGcaUxnfqlOrjAMcuGVLg_mD3_1O57BrKBiIjJgGSnKsRCdWchteLPB9T0lLECy5ASTiKo__HRPizMw9tUCXGwS6zC5F-q4HugYtZtXVy_HBBmEk4qbi_R0ovEZb8n1zLHF4843A1zcZruI80fonj9qiOXLyUJfzinfv0TQI");
// ResponseEntity<Map> resp = new RestTemplate().exchange("http://c-test.clamc.com/api/operation-ia-message/send", HttpMethod.POST, entity, Map.class);
// "true".equals(resp.getBody().get("rel").toString()) 该信息正确的时候邮件发送成功

posted on 2020-10-22 18:15  pokeTwo  阅读(205)  评论(0编辑  收藏  举报