Solved

HTTP Post

Posted on 2013-06-17
2
342 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

15 Experts available now in Live!

Get 1:1 Help Now