Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objHTTP.Open unable to compile

Tags:

vba

ms-access

I am attempting to send a POST URL message from MS Access VBA. When I attempt to run the code, it tells me that is not able to compile the following statement. Does anyone have any idea where I am incorrect in my syntax? Thank you in advance for assistance.

objHTTP.Open "POST", "http://kt1.com/apiv2/Configuration.asmx", False

The full code is:

Private Sub newKT_WebService_Click()
    Dim objHTTP As String
    Dim replyTXT As String
    Dim AuthCode As String

    objHTTP = CreateObject("MSXML2.ServerXMLHTTP")

    objHTTP.Open "POST", "http://kt1.com/apiv2/Configuration.asmx", False

    objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    objHTTP.send ("CallingID=12345&token=%20&domain=%20&userName=testuser&password=testpassword")

    MsgBox objHTTP.responseText

End Sub
like image 221
Jason Miller Avatar asked Aug 15 '26 07:08

Jason Miller


1 Answers

objHTTP was declared as String. But later the code attempts to assign an object reference to it. So declare objHTTP as Object. And you must use the Set keyword to assign to the object variable.

Dim objHTTP As Object
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", "http://kt1.com/apiv2/Configuration.asmx", False

I'm not really familiar with MSXML2.ServerXMLHTTP but hopefully those changes will allow the code to compile and do what you need.

like image 134
HansUp Avatar answered Aug 17 '26 02:08

HansUp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!