zoukankan      html  css  js  c++  java
  • 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()) 该信息正确的时候邮件发送成功

  • 相关阅读:
    有个表叫杨表(上)
    Codeforces Round #698 (Div. 2) 题解 全部6题
    Leetcode 821. 字符的最短距离
    gitbook mermaid不能渲染问题
    adb命令启动app及查找系统版本号
    git库使用
    excle转html方法
    gitbook插入视频
    xcode使用技巧
    在 Mac 上的“自动操作”工作流程中使用 Shell 脚本操作
  • 原文地址:https://www.cnblogs.com/dwt520/p/13860191.html
Copyright © 2011-2022 走看看