Posting data to a url

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I post data to a url and get the status code back in vb.net? In the
past I have used the below code in vba whose vb.net equivalent I am looking
for.

Set oHttpPost = CreateObject("Microsoft.XMLHTTP")
oHttpPost.Open "POST", MyUrl, False
oHttpPost.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
POSTData = "Some data here"
oHttpPost.Send (POSTData)
If oHttpPost.status = 200 Then
St = oHttpPost.responseText
End If

Thanks

Regards
 
See System.Net.WebClient. It allows to send http requests and you
already have a method (UploadData if I remember) that allows to post
name/value pairs. Should be enough (you also have lower level classes
to take the control of the whole http request).
 
Back
Top