請教各位先進,小弟公司的合作廠商提供了WebAPI供資料上傳
下面是小弟的程式碼
現在的狀況是送出需求後,無任何回應
因為是第一次接觸JSON,還請各位指正內容哪裡有誤,謝謝
Private sub connectPK()
Dim strXml As String
Dim token As String, strServer As String
Dim varA As String
Dim varB As String
Dim varC As String
Dim yyy As New MSXML2.XMLHTTP60
'日期參數
token = "xxx_2019-09-09"
'api網址
strServer = "https://test123.goodwill.com/services/d-rec"
'內容參數
varA = "A099"
varB = "testA011"
varC = "testA011A"
Dim sInputJson As String
'JSON內容
sInputJson = "{ ""token"": """ & token & """ , ""requests"": [{ ""codeA"": """ & varA & """, ""codeB"": """ & varB & """, ""codeC"": """ & varC & """}] }"
'用POST方式
yyy.Open "POST", strServer , False
yyy.setRequestHeader "Content-type", "application/json; charset=utf-8"
On Error Resume Next
yyy.send sInputJson
While yyy.ReadyState <> 4
MsgBox "連結失敗"
Wend
strResponse = yyy.responseText
yyy.abort
On Error GoTo 0
End sub