How to send http post request in ASP

Discussion in 'ASP General' started by inferno2000@my-deja.com, Jan 26, 2006.

  1. Guest

    Let's say if I want to send a http "Post" request to a url, and check
    the http status code later. How should I write the code? I have found
    example to use WinHttp to send "Get" request and check the http status
    code:

    ======
    Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5")
    objWinHttp.Open "GET", strURL
    objWinHttp.Send
    If objWinHttp.Status <> 200 Then
    ...
    End If
    ======

    How should I write the code if I need to use "POST" to send data in a
    form, and to check the http status code later?
     
    , Jan 26, 2006
    #1
    1. Advertising

  2. <> wrote in message news:...
    > Let's say if I want to send a http "Post" request to a url, and check
    > the http status code later. How should I write the code? I have found
    > example to use WinHttp to send "Get" request and check the http status
    > code:
    >
    > ======
    > Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5")
    > objWinHttp.Open "GET", strURL
    > objWinHttp.Send
    > If objWinHttp.Status <> 200 Then
    > ...
    > End If
    > ======
    >
    > How should I write the code if I need to use "POST" to send data in a
    > form, and to check the http status code later?
    >


    Try something like the following:

    Set oXmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP.4.0")
    With oXmlHttp
    .open "POST", strURL, False
    .send strMessageToSend
    If (oXmlHttp.status <> 200) Then
    ' received some other return status, handle it
    ...
    End If
    End With
    Set oXmlHttp = Nothing

    Regards, Marja
     
    Marja Ribbers-de Vroed, Jan 26, 2006
    #2
    1. Advertising

  3. Guest

    Marja Ribbers-de Vroed wrote:
    > Try something like the following:
    >
    > Set oXmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP.4.0")
    > With oXmlHttp
    > .open "POST", strURL, False
    > .send strMessageToSend


    Thank you, I will try that.
     
    , Jan 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZXN3YW5zb24=?=

    asp.net form to send a request to a put request

    =?Utf-8?B?ZXN3YW5zb24=?=, Oct 29, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    606
    =?Utf-8?B?ZWpz?=
    Nov 9, 2004
  2. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,063
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  3. Replies:
    6
    Views:
    5,134
    Tor Iver Wilhelmsen
    Aug 29, 2005
  4. James
    Replies:
    3
    Views:
    16,384
    Roedy Green
    Nov 25, 2005
  5. Nacho Nachev
    Replies:
    2
    Views:
    908
Loading...

Share This Page