"errcode":71009,"errmsg":"返回文本非success, HTTP請求結果校驗返回字段值失敗
[HttpPost("dingtalk")] public JsonResult dingtalk([FromBody]DingDtos entitydto) { StringValues msgSignature = string.Empty; Request.Query.TryGetValue("signature", out msgSignature); StringValues timestamp = string.Empty; Request.Query.TryGetValue("timestamp", out timestamp); StringValues nonce = string.Empty; Request.Query.TryGetValue("nonce", out nonce); string encryptStr = entitydto.encrypt; string encrypt = string.Empty; string AesKey = "2e5mst3754bg5dv4639ahukj04dwmwzt4d6ps322jhr";//43位隨機 string Token = "123456";//加解密需要用到的token,普通企業可以隨機填寫 string suiteKey = "dinga9XXXX";// 基本信息開發信息中 string signatureNew = string.Empty; //DingTalkCrypt dingTalkCrypt = new DingTalkCrypt(Token, AesKey, suiteKey); DingTalkEncryptor dingTalkCrypt = new DingTalkEncryptor(Token, AesKey, suiteKey); //解密 string EventType = dingTalkCrypt.getDecryptMsg(msgSignature, timestamp, nonce, encryptStr); Hashtable tb = (Hashtable)JsonConvert.DeserializeObject(EventType, typeof(Hashtable)); string eventType = tb["EventType"].ToString(); switch (eventType) { case "bpms_task_change"://審批任務開始,結束,轉交 #region 審批任務開始,結束,轉交 #endregion break; case "bpms_instance_change"://審批實例開始,結束 #region 審批實例開始,結束 string processCode = tb["processCode"].ToString(); #region 審批實例開始,結束 #endregion #endregion break; } //dingTalkCrypt = new DingTalkCrypt(Token, AesKey, suiteKey); #region 加密返回數據,必須要有,無需修改 //加密 //dingTalkCrypt.EncryptMsg("success", timestamp, nonce, ref encrypt, ref signatureNew); Dictionary<String, String> resultMap= dingTalkCrypt.getEncryptedMap("success",SysConvert.ToLong(timestamp)); //查看解密結果是否是success string evne = dingTalkCrypt.getDecryptMsg(resultMap["msg_signature"], resultMap["timeStamp"], resultMap["nonce"], resultMap["encrypt"]); //dingTalkCrypt.DecryptMsg(signatureNew, timestamp, nonce, encrypt, ref evne); //SysFile.WriteFrameworkLog("查看解密結果是否是success:" + evne); DingDingBack back = new DingDingBack(); back.msg_signature = resultMap["msg_signature"]; back.encrypt = resultMap["encrypt"]; back.timeStamp = resultMap["timeStamp"]; back.nonce = resultMap["nonce"]; //SysFile.WriteFrameworkLog("返回json:" + new JsonResult(back)); return new JsonResult(back); #endregion }
特別注意:
string suiteKey = "dinga9XXXX";// 基本信息開發信息中