以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- HttpClient的post请求问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=173724) |
-- 作者:z769036165 -- 发布时间:2021/12/13 16:20:00 -- HttpClient的post请求问题 在对方的网页API测试环境中post请求参数: curl -X POST "http://192.168.3.10:8088/api/services/Org/UserLogin" -H "accept: application/json" -H "Content-Type: text/json" -d "{ \\"UserName\\": \\"000001\\", \\"Password\\": \\"12345\\", \\"DomainIp\\": \\"\\", \\"DeviceId\\": \\"\\", \\"WeChatName\\": \\"\\", \\"IsWechatType\\": \\"\\", \\"ClientType\\": \\"\\", \\"UserHostAddress\\": \\"\\", \\"ValidateCodeSms\\": \\"\\"}" 测试请求的参数是这样的 { "UserName": "000001", "Password": "12345", "DomainIp": "", "DeviceId": "", "WeChatName": "", "IsWechatType": "", "ClientType": "", "UserHostAddress": "", "ValidateCodeSms": "" } 返回结构 { "data": "0064a97bae66bf3647f29aad065d67975a38", "dataDescription": "", "result": 0, "message": "" } 但是我用HttpClient请求结果没有返回任何结果 Dim url As String = "http://192.168.3.10:8088/api/services/Org/UserLogin" Dim hc As New HttpClient(url) Dim jo As New JObject jo("UserName") = "000001" jo("Password") = "12345" jo("DomainIp") = "" jo("DeviceId") = "" jo("WeChatName") = "" jo("IsWechatType") = "" jo("ClientType") = "" jo("UserHostAddress") = "" jo("ValidateCodeSms") = "" Output.Show(jo.tostring) hc.FormData.Add("userDto",jo.tostring) Dim ret As String = hc.GetData Output.Show(ret) 返回结果是一个空,这个是哪的问题? [此贴子已经被作者于2021/12/13 16:20:18编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/12/13 16:23:00 -- Dim url As String = "http://192.168.3.10:8088/api/services/Org/UserLogin" Dim hc As New HttpClient(url) hc.ContentType = "application/json" Dim jo As New JObject jo("UserName") = "000001" jo("Password") = "12345" jo("DomainIp") = "" jo("DeviceId") = "" jo("WeChatName") = "" jo("IsWechatType") = "" jo("ClientType") = "" jo("UserHostAddress") = "" jo("ValidateCodeSms") = "" Output.Show(jo.tostring) hc.Content = jo.tostring Dim ret As String = hc.GetData Output.Show(ret)
[此贴子已经被作者于2021/12/13 16:23:52编辑过]
|
-- 作者:z769036165 -- 发布时间:2021/12/13 16:42:00 -- 非常感谢,可以了,被对方的API文档误导了,对方写了POST请求,并写了传入字段为userDto |