I am writing some code in an asp application that needs to communicate with a PHP REST Service.
I have 2 questions.
1. In my data variable I have to put the POST parameters. If I needed to put reserved characters like & or ? into the string is there an escape character I can use? Or would encoding it work? Or would it totally depend on how the web service works?
2. Is the code I am using the usual way to make a POST connection to a REST service? Or is there an easier/faster way?
Below is the code I am using Dim uri As New Uri("http://help.domain.com/api/index.php?method=request.create")
Dim data As String = "tNote=Testing Code&sEmailfirstname.lastname@example.org"
If uri.Scheme = uri.UriSchemeHttp Then
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Post
request.ContentLength = data.Length
request.ContentType = "application/x-www-form-urlencoded"
Dim writer As New StreamWriter(request.GetRequestStream)
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
View Complete Post