Solved

HTTP Post

Posted on 2013-06-17
2
344 Views
Last Modified: 2013-06-18
In VB.Net, how can I test the ability to make an HTTP Post to a URI?
0
Comment
Question by:lrbrister
2 Comments
 
LVL 25

Accepted Solution

by:
Ron M earned 500 total points
ID: 39254725
http://stackoverflow.com/questions/8222092/sending-http-post-with-system-net-webclient


..here's a piece of code I made that seems to work.
Imports System.Web

 Dim MyClient As New WebClient
 
       Dim ServerResponse as string = ""
        Dim WebRequestString As String = ""
        Dim   OutURL As String = "http://www.yourdomain.com/yourpostpage.php"

'Add some form values
MyClient.QueryString.Add("keyname", "keyvalue")

       Try
              MyClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

              Dim bytResponse As Byte() = MyClient.UploadValues(OutURL, MyClient.QueryString)

              ServerResponse = System.Text.ASCIIEncoding.ASCII.GetString(bytResponse)

        Catch ex As Exception
                                FinalResult = ex.Message
                                FailureTrackCount = FailureTrackCount + 1
        End Try

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 39257050
Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now