以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 外部接口调用 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=187422) |
-- 作者:kk000 -- 发布时间:2023/7/17 16:01:00 -- 外部接口调用 Dim hc As New HttpClient("http://localhost/U8ErpWebApi//api/allinone/json") hc.Headers.add("Content-Type", "application/json") hc.Headers.add("Accept", "*/*") hc.Headers.add("Host", "localhost") hc.Headers.add("Connection", "keep-alive") Dim jo1 As new JObject Dim jo2 As new JObject jo1("subid") = "ST" jo1("accid") = "999" jo1("userid") = "demo" jo1("password") = "DEMO" jo1("appserver") = "localhost" jo2("cVouchType") = "1" jo2("cOptType") = "query" jo2("cVouchID") = "1000000399" jo("context") = jo1 jo("data") = jo2 Output.Show(jo.Tostring) hc.Content = jo.ToString() Output.Show(jn.ToString) 请教下 API接口调用 , 以上代码 , 但不成功 , 下副 接口调试工具的结果, 请问我 写方法有错吗? 以下是 python的例子 import http.client import json conn = http.client.HTTPSConnection("localhost") payload = json.dumps({ "context": { "subid": "ST", "accid": "999", "userid": "demo", "password": "DEMO", "appserver": "localhost" }, "data": { "cVouchType": "1", "cOptType": "query", "cVouchID": "1000000399" } }) headers = { \'User-Agent\': \'Apifox/1.0.0 (https://apifox.com)\', \'Content-Type\': \'application/json\' } conn.request("POST", "/U8ErpWebApi//api/allinone/json", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) [此贴子已经被作者于2023/7/17 18:22:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/7/17 20:06:00 -- 接口文档发过来看看 |
-- 作者:kk000 -- 发布时间:2023/7/17 22:22:00 -- 改一下书写方法 就行了 可以了 谢谢! ContentType 这个属性 tab 不出来 ,最好追加一下
[此贴子已经被作者于2023/7/17 22:23:13编辑过]
|