passing web page parameters with http

I’m trying to convert the following VB.NET function into Xojo:

Dim sp_return As String = “Error”
Dim authkey As String = “”
Dim params As String = “authKey=” + authkey + “&stringToEncrypt=” + strToEncrypt

Dim myWebRequest As HttpWebRequest = WebRequest.Create("")
Dim mybuffer() As Byte = System.Text.Encoding.ASCII.GetBytes(params)
myWebRequest.Method = “POST”
myWebRequest.ContentType = “application/x-www-form-urlencoded”
myWebRequest.ContentLength = mybuffer.Length
Dim mydataStream As Stream = myWebRequest.GetRequestStream()
mydataStream.Write(mybuffer, 0, mybuffer.Length)
Dim myWebResponse As HttpWebResponse = myWebRequest.GetResponse()
Dim myStreamReader As StreamReader = New StreamReader(myWebResponse.GetResponseStream())
Dim pagecontents As String = myStreamReader.ReadToEnd

I think that a lot of what is in there isn’t needed in Xojo. It seems like this ought to convert to:

dim objhttp as new HTTPSecureSocket
Dim sp_return As String = “Error”
Dim authkey As String = “”
dim pagecontents as string=objhttp.get("",30)

However that returns an error telling me the authkey is bad (which could just be the default error). If I switch the objhttp.get to, then I get an error returned saying that the content length needs to be set, but I’m not sure how to set that.

Any suggestions on how to fix this would be appreciated.

To post a URL-encoded form, convert “params” into a Dictionary and then call objhttp.SetFormData:

Dim form As New Dictionary form.Value("authKey") = authkey form.Value("stringToEncrypt") = strToEncrypt objhttp.SetFormData(form) dim pagecontents as string=objhttp.Post("<web address here>",30)

That worked. Thanks so much.