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 jo As New JObject
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()
Dim jn As JObject = Jobject.Parse(hc.GetData)
Output.Show(jn.ToString)
请教下 API接口调用 , 以上代码 , 但不成功 , 下副 接口调试工具的结果, 请问我 写方法有错吗?
此主题相关图片如下:1689584839836.png
以下是 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编辑过]