none
XMLHttp object - multiple line header RRS feed

  • Question

  • ACCESS 2000 Vba Win XP

    I want to use the XMLHttp Object to POST to a REST API.

    Using the Winsock control I can send:-

    POST /services/rest/sms HTTP/1.0
    Host: sandbox.textmarketer.biz
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 132 [Note - this is correct but does not match the message length below becuase I have altered values of username and Pw.]

    message=Come%20and%20have%20a%2010%25%20off%20%2D%20SMS&mobile%5Fnumber=07786263868&originator=Oval&username=MyUserName&password=MyPwn
    message=this&mobile_number=07919283968&originator=me

    AND get an appropriate response

    HOWEVER - I need to do thsi many times quickly and to avoid the "address in use" error need to reset the port to port = 0 each time and run the danger of running out of ports

    SO:- I want to try using the XMLHttp object as an alternative.

    I can open the object and send the host address username and password fine.

    BUT:- I have a problem with defining the Header. It is required by the REST Api that the Header has to include 2 lines:-

    Content-Type: application/x-www-form-urlencoded
    Content-Length: 132

    I have looked at http://www.w3.org/TR/XMLHttpRequest/

    It says (section 4.7.2) that "Content-Length" is not allowed [and my app reports this when I try to add it!]

    The article above says that this addition is "left up to the user agent" -

    I HAVE NO IDEA WHAT THIS MEANS.

    SO:-

    a. am I barking up the wrong tree trying to use the HTPPHtml object OR

    b. Is there a way for me to add the second line of the header required using vba OR

    c. is there some other alternative object I can use in vba as an alternative to the Winsock control

    Jim Bunton

     


    Jim Bunton

    Wednesday, March 28, 2012 11:06 PM