以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]PUT方式提交后请求体没发送过去 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=173908) |
||||
-- 作者:wh123 -- 发布时间:2021/12/22 9:22:00 -- [求助]PUT方式提交后请求体没发送过去 通过PU方式调用接口,请求体没有传过去 具体代码如下: Dim hc As New HttpClient("https://smlopenapi.esign.cn/v1/accounts/230ffb2c61764a9fbc7e677a79d93ed5") Dim jo As New JObject jo("email") = "测试@163.com" hc.Content = jo.ToString hc.C hc.Method = "put" hc.Accept = "*/*" hc.Headers.Add("X-Tsign-Open-App-Id", "7438895632") Dim st As New Date(1970,1,1,8,0,0) Dim timestamp As Long = CLng((Date.Now - st).TotalMilliseconds()) \'时间戳 hc.Headers.Add("X-Tsign-Open-Ca-Timestamp", timestamp) Dim ContentMD5 As String = Functions.Execute("getContentMD5",jo.ToString) Dim HTTPMethod As String = "PUT" Dim Accept As String = "application/json" Dim ContentType As String = "application/json" Dim dt As String = "" Dim Headers As String = "" Dim Url As String = "https://smlopenapi.esign.cn/v1/accounts/230ffb2c61764a9fbc7e677a79d93ed5" Dim Signature As String = HTTPMethod & "\\n" & Accept & "\\n" & ContentMD5 & "\\n" & ContentType & "\\n" & dt & "\\n" & Headers & Url Dim myEncoder As New System.Text.UTF8Encoding Dim Key() As Byte = myEncoder.GetBytes("6750131f1fe86bcfbabea0e628039685") \'应用密钥 Dim zifuchuan() As Byte = myEncoder.GetBytes(Signature) Dim myHMACSHA256 As New System.Security.Cryptography.HMACSHA256(Key) Dim HashCode As Byte() = myHMACSHA256.ComputeHash(zifuchuan) Dim result As String = Convert.ToBase64String(HashCode) hc.Headers.Add("X-Tsign-Open-Ca-Signature",result) \'签名字符串 hc.Headers.Add("Content-MD5",ContentMD5) \' hc.Headers.Add("X-Tsign-Open-Auth-Mode","Signature") Dim ret As JObject = Jobject.Parse(hc.GetData) Output.Show(ret.ToString )
|
||||
-- 作者:wh123 -- 发布时间:2021/12/22 9:26:00 -- hc.ContentType 这个属性发不出来变成 hc.C了 值是 "application/json; charset=UTF-8" |
||||
-- 作者:有点蓝 -- 发布时间:2021/12/22 9:36:00 -- 开发文档发过来看看 |
||||
-- 作者:wh123 -- 发布时间:2021/12/22 9:50:00 -- 附件是这个接口的文档, |
||||
-- 作者:wh123 -- 发布时间:2021/12/22 10:15:00 --
|
||||
-- 作者:wh123 -- 发布时间:2021/12/22 10:16:00 -- https://open.esign.cn/doc/detail?id=opendoc%2Fsaas_api%2Ftzi4kd_ma1d8m&namespace=opendoc%2Fsaas_api 或者直接到这个地址看
|
||||
-- 作者:有点蓝 -- 发布时间:2021/12/22 10:21:00 -- 有没有原版的接口文档链接? 请求失败提示什么错误? Dim Accept As String = "application/json"不应该是Dim Accept As String = "*/*"?
|
||||
-- 作者:wh123 -- 发布时间:2021/12/22 11:11:00 -- 两者都可以,网址里面就是原版,没有下载下来的文档,易签宝的 |
||||
-- 作者:wh123 -- 发布时间:2021/12/22 11:12:00 -- 报错400错误的请求,那边技术说看了是没有请求体数据导致的,但是上面请求体加了的 |
||||
-- 作者:有点蓝 -- 发布时间:2021/12/22 11:15:00 -- 里面有.net的实例:https://qianxiaoxia.yuque.com/docs/share/a63b789c-37d5-48b8-a73b-dee7b2bc0f92 参考着做。c#转换为vb.net参考:https://converter.telerik.com/
|