以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 按照图片所示我的请求是不是缺少什么? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=148621) |
-- 作者:blackzhu -- 发布时间:2020/4/11 12:20:00 -- 按照图片所示我的请求是不是缺少什么? 图片: { "state": 2, "data": null, "msg": "无权限访问", "ext": {} } Dim jo1 As New JObject jo1("username") = "xxx" jo1("password") = "xxx" Dim hc As New HttpClient("https://www.bidding.csg.cn:8080/api/WZGYL/scp-supplier-erp/getAccessToken") hc.Headers.Add("Content-Type", "application/json;charset=UTF-8") hc.Content = jo1.Tostring() If hc.GetInformation() Then Dim ret As String = hc.GetData() MessageBox.Show(ret) End If 但是我这个请求返回了服务404 [此贴子已经被作者于2020/4/11 12:25:42编辑过]
|
-- 作者:speedIM -- 发布时间:2020/4/11 12:45:00 -- Dim result As String Try Dim web As New System.Net.WebClient() web.Proxy = Nothing web.Headers.Add("Content-Type", "application/json") Dim body As New Newtonsoft.Json.Linq.JObject body("username") = "xxx" body("password") = "xxx" result = web.UploadString("xxx", body.ToString()) Catch ex As System.Net.WebException Dim stream As System.IO.Stream = ex.Response.GetResponseStream() Dim reader As New System.IO.StreamReader(stream) result = reader.ReadToEnd() End Try [此贴子已经被作者于2020/4/11 12:45:03编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/4/11 13:47:00 -- 一般是请求地址不正确 Dim hc As New HttpClient("https://www.bidding.csg.cn:8080/api/WZGYL/scp-supplier-erp/getAccessToken")
|
-- 作者:blackzhu -- 发布时间:2020/4/11 16:08:00 -- 请求的地址是对的,二楼的方法就是可以获取的 |
-- 作者:有点蓝 -- 发布时间:2020/4/11 16:33:00 -- Dim hc As New HttpClient("https://www.bidding.csg.cn:8080/api/WZGYL/scp-supplier-erp/getAccessToken") hc.ContentType = "application/json;charset=UTF-8" hc.Content = jo1.Tostring()
|