Results 1 to 4 of 4

Thread: VB6 WinHttp not working

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2013
    Posts
    7

    VB6 WinHttp not working

    Code:
                    Dim HTTP
                    Set HTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
                    HTTP.setTimeouts 50000, 50000, 50000, 50000
                    HTTP.Open "POST", sAddress, True
                    HTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & ""
                    'On Local Error Resume Next
                    HTTP.send Data
                    resp = HTTP.responseText
    We have an old VB6 Project that we are updating.

    After a client asked for changes, the above code stopped working

    On the HTTP.send, we get "the data necessary to complete this operation is not yet available"

    Been searching Google but can not find a good solution.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,543

    Re: VB6 WinHttp not working

    This isn't the correct part of the forum for posting questions. It is used for posting sample code/projects that can be used as-is.

    I've notified the moderators so that they can move this to the proper forum section for you
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,474

    Re: VB6 WinHttp not working

    Quote Originally Posted by XardozCom View Post
    Code:
                    Dim HTTP
                    Set HTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
                    HTTP.setTimeouts 50000, 50000, 50000, 50000
                    HTTP.Open "POST", sAddress, True
                    HTTP.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & ""
                    'On Local Error Resume Next
                    HTTP.send Data
                    resp = HTTP.responseText
    We have an old VB6 Project that we are updating.

    After a client asked for changes, the above code stopped working

    On the HTTP.send, we get "the data necessary to complete this operation is not yet available"

    Been searching Google but can not find a good solution.
    The first mistake I see, is that you are using the HTTP-Object in async-mode (last Param in the Open-method).
    So don't expect to get anything useful returned in your last line:
    resp = HTTP.responseText
    shortly after sending the request (asynchronously).

    Though since you apparently get the error already when you call the Send-method,
    I'd suspect that what you've passed in your Data-Variable was not valid multipart/form-data
    content - or (more likely) 'Data' even being "completely emtpy yet".

    Olaf

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2013
    Posts
    7

    Re: VB6 WinHttp not working

    Sorry for the mis-post.

    Thank you Olaf, I found the solution as you posted

    Issue solved.
    Below causes the issue, ASYNC=True
    Code:
    HTTP.Open "POST", sAddress, True
    This works! ASYNC=False
    Code:
    HTTP.Open "POST", sAddress, False
    Last edited by XardozCom; Sep 20th, 2014 at 05:05 PM.

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
  •  



Click Here to Expand Forum to Full Width