Posting data to a url

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
 
P

Patrice

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).
 

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

Top