How to send http post request in ASP

I

inferno2000

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?
 
M

Marja Ribbers-de Vroed

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
 
I

inferno2000

Marja said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top