[英]Error sending JSON object as a POST request [VB.NET]
我正在嘗試從VB.NET應用程序(3.5 Framework)發送JSON對象。
我正在使用此代碼:
Private Function sendSMS()
Dim objHTTP As Object
Dim json As String
Dim result As String
Dim URL As String
json = fJSON()
objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "https://api.XXXXXXXXX.com/api/3.0/sms/send"
objHTTP.Open("POST", URL, False)
objHTTP.setRequestHeader("Content-type", "application/json")
objHTTP.send(json)
result = objHTTP.responseText
objHTTP = Nothing
End Function
Private Function fJSON() As String
fJSON = "{"
fJSON = fJSON & """api_key"":""XXXXXXXXXXXXXXXXXXX"","
fJSON = fJSON & """concat"":1,"
fJSON = fJSON & """fake"":1,"
fJSON = fJSON & """messages"":["
fJSON = fJSON & "{"
fJSON = fJSON & """from"":""SHOP"","
fJSON = fJSON & """to"":""3400000000"","
fJSON = fJSON & """text"":""LOREM IPSUM"""
fJSON = fJSON & "}]}"
End Function
但是我在行代碼中收到此錯誤:
行代碼:
objHTTP.setRequestHeader("Content-type", "application/json")
錯誤:
System.Runtime.InteropServices.COMException(0x80004005):錯誤沒有說明
怎么了?
有時,用戶沒有足夠的特權來運行某些COM方法。 在這里,您的異常顯示基於System.Runtime.InteropServices.COMException的“ System.Runtime.InteropServices.COMException(0x80004005)”。 為了解決這個問題,您是否可以以管理員身份運行Visual Studio,並檢查該邏輯是否對您有用?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.