Foxtable(狐表)用户栏目专家坐堂 → postman提交没问题,HttpClient提交有问题


  共有2461人关注过本帖树形打印复制链接

主题:postman提交没问题,HttpClient提交有问题

帅哥哟,离线,有人找我吗?
aidimeng
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:802 积分:7702 威望:0 精华:0 注册:2015/9/14 14:26:00
postman提交没问题,HttpClient提交有问题  发帖心情 Post By:2024/1/15 12:15:00 [显示全部帖子]

在postman上提交报文没问题,通过HttpClient 提交提示 远程服务器返回错误: (405) 不允许的方法
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:水表接入规范v20231219.zip



图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20240115121421.png
图片点击可在新窗口打开查看

 Dim version As String = "1.0"
'   Dim encoding As String = "utf8"
 Dim BasicTime As New Date(1970, 1, 1, 8, 0, 0)
Dim NowTime As Date = Date.Now '当前时间
Dim TimeStamp As Long = CLng((NowTime - BasicTime).TotalSeconds())
Dim imei_no As String = "65270065264270"
Dim meter_no As String = "53188028"
Dim jo1 As New JObject
jo1("imei_no") = imei_no 
jo1("meter_no") = meter_no 
Dim s As String = CompressJson(jo1)
 Dim content As String = Convert.ToBase64String(Encoding.UTF8.GetBytes(s))
Output.Show("content:" & content)
 Dim signature As String = content & version & "utf8" & TimeStamp & "10" & version & "123456"
 signature = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signature, "MD5").Tolower
Output.Show("signature:" & signature)
Dim url As String = "https://www.iotmeter.top:91/api/meterOperate"
Dim jo As New JObject
jo("version") = version
jo("encoding") = "utf8"
jo("timestamp") = timestamp
jo("signature") = signature
jo("signmethod") = "01"
jo("transtype") = "10"
jo("content") = content
Dim hc As New HttpClient(url)
hc.C
 Dim s1 As String = CompressJson(jo)
 Output.Show(s1)
Dim ret As String = hc.GetData()
Output.Show(ret)
 远程服务器返回错误: (405) 不允许的方法
[此贴子已经被作者于2024/1/15 12:27:27编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:802 积分:7702 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2024/1/15 15:34:00 [显示全部帖子]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:111.txt

必须先将 ContentLength 字节写入请求流,然后再调用 [Begin]GetResponse。

 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:802 积分:7702 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2024/1/15 16:24:00 [显示全部帖子]

还是一样的提示
 Dim signature As String = cexp("content={0}&encoding=utf8&signmethod=01&timestamp={1}&transtype=10&version=1.0&key=123456", content , TimeStamp)
signature = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signature, "MD5").Toupper
Dim url As String = "https://www.iotmeter.top:91/api/meterOperate/"
Dim jo As New JObject
jo("version") = version
jo("encoding") = "utf8"
jo("timestamp") = timestamp
jo("signature") = signature
jo("signmethod") = "01"
jo("transtype") = "10"
jo("content") = content
Dim hc As New HttpClient(url)
hc.C
 Dim s1 As String = CompressJson(jo)
  Output.Show(s1) ‘显示;{"version":"1.0","encoding":"utf8","timestamp":1705306964,"signature":"153689B8AB7E968CE0718F2A2D6191D7","signmethod":"01","transtype":"10","content":"eyJpbWVpX25vIjoiNjUyNzAwNjUyNjQyNzAiLCJtZXRlcl9ubyI6IjUzMTg4MDI4In0="}
 hc.Content = s1
Dim ret As String = hc.GetData()
Output.Show(ret)
[此贴子已经被作者于2024/1/15 16:25:35编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
aidimeng
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:802 积分:7702 威望:0 精华:0 注册:2015/9/14 14:26:00
  发帖心情 Post By:2024/1/15 16:41:00 [显示全部帖子]

感谢感谢,终于可以了,辛苦了

 回到顶部