|
-
Mar 11th, 2021, 11:37 AM
#1
Thread Starter
Member
WinHttpRequest - errors like 'method cannot be called until open/send has been called
Hi,
After both Opening and Sending a request, some of the propertes of a WinHttpRequest are displaying errors.
Code:
On Error Resume Next
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
Request_s = "GET"
objHTTP.Open Request_s, Url_s, False
objHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHTTP.SetCredentials User_s, Password_s, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
objHTTP.Send Credentials_s
'// BELOW, Status (and ResponseBody and ResponseText, etc.) are showing that the request hasn't been sent, even though it just was.
'// ALSO, the Option property says that the Open method must be called.
Status_n = objHTTP.Status
Status_Text_s = objHTTP.StatusText
HTML_s = objHTTP.ResponseText
-
Mar 11th, 2021, 11:45 AM
#2
Re: WinHttpRequest - errors like 'method cannot be called until open/send has been ca
Try objHTTP.Send CVar(Credentials_s)
This is a known bug with Send method where the argument cannot have VT_BYREF flag set i.e. cannot be an l-value (like a plain variable) and must be an expression of some form.
cheers,
</wqw>
-
Mar 11th, 2021, 12:33 PM
#3
Thread Starter
Member
Re: WinHttpRequest - errors like 'method cannot be called until open/send has been ca
Thanks, wq. I tried enclosing the variable with CVar, but the properties are still empty.
This has to be the way in which the credentials are being delivered. The Credentials_s parameter with Send, is actually redundant because SetCredentials is already used. However, I tried removing the SetCredentials call ; and tried leaving it and removing the CVar( Credentials_s ) parameter from the Send.
I DID notice that, after Open is executed, the url_s is considered invalid. (I can link to it, in a browser). I'll try this with a different url.
Last edited by VBExplorer12; Mar 11th, 2021 at 12:56 PM.
-
Mar 11th, 2021, 01:03 PM
#4
Thread Starter
Member
Re: WinHttpRequest - errors like 'method cannot be called until open/send has been ca
Got it. The problem is that the tool that I'm using - VBSedit - requires the temporary command line parameters to be separated by spaces. I had them separated by commas and spaces.
So the Url_s was being interpreted as something like " 'www.thissite.com', "
Thanks for the tip, wq. Noted for the future.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|