url=http://abc.net/api/sap/GetSalesContract?factory_code=hh&vbeln=YZ-TJ-ZLY-22120047&kunnr=0020110135用户名:api1
密码:1q2w3e4r
验证方式:Basic Auth
请求方式 get
使用httpclient 怎么写啊,涉及到headers 中怎么写用户,密码和验证方式啊
这样写可以吗? 我试了下 可以验证过去
Dim hc As New HttpClient("http://abc.net/api/sap/GetSalesContract?factory_code=hh&vbeln=YZ-TJ-ZLY-22120047&kunnr=0020110135")
hc.Headers.Add("Authorization", "Basic YXBpMToxcTJ3M2U0cg==")
hc.Headers.Add( "username", "api1")
hc.Headers.Add("password", "1q2w3e4r")
Dim jo As JObject = Jobject.Parse(hc.GetData)
Output.Show(jo.ToString)
这里的参数可以这样写吗? 怎么传参啊
Dim hc As New HttpClient("http://abc.net/api/sap/GetSalesContract?factory_code={0}&vbeln={1}&kunnr={2}")
Dim username As String = "wapi1" '
Dim password As String = "1q2w3e4r" '
Dim factory_code As String = "hh"
Dim zyghtbm As String = "BZY-HH-23080965"
Dim kunnr As String = "0020110135"
Dim url As String = "http://abc.net/api/sap/GetSalesContract?factory_code={0}&vbeln={1}&kunnr={2}"
Dim hc As New HttpClient(CExp(url, factory_code, zyghtbm, kunnr))
hc.Headers.Add("Authorization", "Basic YXBpMToxcTJ3M2U0cg==")
hc.Headers.Add( "username", "api1")
hc.Headers.Add("password", "1q2w3e4r")
Dim jo As JObject = Jobject.Parse(hc.GetData)
Output.Show(jo.ToString)
[此贴子已经被作者于2023/9/18 20:05:20编辑过]