Foxtable(狐表)用户栏目专家坐堂 → 调用接口,post形式


  共有350人关注过本帖平板打印复制链接

主题:调用接口,post形式

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


加好友 发短信
等级:童狐 帖子:268 积分:2183 威望:0 精华:0 注册:2020/9/28 14:53:00
调用接口,post形式  发帖心情 Post By:2024/5/10 10:49:00 [只看该作者]

使用以下代码,运行错误,未能创建 SSL/TLS 安全通道。如何处理


Dim name As String="张三"
Dim id As String="abc"
Dim msg As String = "username=" & name &"&idcard=" & id 
msgbox(msg)
Dim req = System.Net.WebRequest.Create("https://certificate/query_json.xhtml")
req.Method = "POST"
req.Timeout = 5000
req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:66.0) Gecko/20100101 Firefox/66.0"
Dim aryBuf As Byte() = Encoding.GetEncoding("utf-8").GetBytes(msg)
req.ContentLength = aryBuf.Length
Dim writer = req.GetRequestStream()
writer.Write(aryBuf, 0, aryBuf.Length)
writer.Close()
writer.Dispose()
Dim pos = req.GetResponse
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim str As String = reader.ReadToEnd
pos.Close
stm.Close
reader.close

msgbox(str)


 回到顶部