更新时间:2023-01-17 08:08:20
您可能已经知道,JSON结构确实会引起严重的麻烦.就您而言,如果要验证您的{test:6, test2: 7}
.
As you probably already know, JSON structure can really produce serious headaches. In your case, I would say its all about the quotes, as you can see in here if you try to validate your {test:6, test2: 7}
.
尝试以下代码.对我来说似乎很合理:
Try the following code. It looks plausible to me:
Sub Post()
Dim URL As String, JSONString As String, objHTTP as Object
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "http://localhost:3000/test"
objHTTP.Open "POST", URL, False
objHTTP.setRequestHeader "Content-type", "application/x-www-form- urlencoded"
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
JSONString = "{""test"": 6,""test2"":7}"
objHTTP.Send JSONString
End Sub