×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

WinHttpRequest - errors like 'method cannot be called until open/send has been called
2

WinHttpRequest - errors like 'method cannot be called until open/send has been called

WinHttpRequest - errors like 'method cannot be called until open/send has been called

(OP)
Hi,

After both Opening and Sending a request, some of the propertes of a WinHttpRequest are displaying errors.


CODE --> VBScript

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 

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

StatusText isn't a variable. However I may be wrong though.

VBS newbie here.

Sincerely,
Bob Space

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

I would suggest that the removal of 'On Error Resume Next" and stepping1 through your code will help immeasurably in identifying what your problem is

1Assuming you have access to a script debugging tool

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

Yeah, that's meant to go where the script could be wrong. Not at the beginning. However I do sorta see what they're going for.

Sincerely,
Bob Space

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

>that's meant to go where the script could be wrong

Actually, I'd advise that you only ever use this when you know exactly what errors may subsequently arise and handling them yourself. And disable it as soon as you are done with your handling. Using it to mask errors in blocks of code simply because you don't know what those errors might be and it seems easiest to just ignore them leads to problems - like the one being experienced here.

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

Thanks for the advice, I've used it before, and I will in advance.

Sincerely,
Bob Space

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

VBSExplorer , have you been able to make progress?

RE: WinHttpRequest - errors like 'method cannot be called until open/send has been called

Guess we give up on this one ...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close