How do I use addrecords from vb.net?

How do I use addrecords from vb.net?

Hello,

I've been tasked with using zoho support for our ticketing system.  As I try to add zoho into our existing web form I have come across an issue.  I really want to use zoho since we plan to use the CRM as well, but I can't get this simple task to work.

Typically when submitting xml data I'd use something like this:

  1. Dim req As System.Net.WebRequest = Nothing
  2.         Dim rsp As System.Net.WebResponse = Nothing
  3.         Dim Request As String = ""
  4.         Request = Request & "authtoken=MyAuthToken&portal=PortalName&department=Support&xml="
  5.         Request = Request & "<requests>"
  6.         Request = Request & "<row no=""1"">"
  7.         Request = Request & "<fl val=""Subject"">Support Request</fl>"
  8.         Request = Request & "<fl val=""Contact Name"">" & tbFirstName.Text & " " & tbLastName.Text & "</fl>"
  9.         Request = Request & "<fl val=""Product Name"">" & tbCompanyName.Text & "</fl>"
  10.         Request = Request & "<fl val=""Email"">" & tbEmail.Text & "</fl>"
  11.         Request = Request & "<fl val=""Phone"">" & tbPhone.Text & "</fl>"
  12.         Request = Request & "<fl val=""Description"">" & tbDescription.Text & "</fl>"
  13.         Request = Request & "</row>"
  14.         Request = Request & "</requests>"
  15.         Try
  16.             Dim url As String = "https://support.zoho.com/api/xml/requests/addrecords?"
  17.             req = System.Net.WebRequest.Create(url)
  18.             req.Method = "POST"
  19.             req.ContentType = "text/xml"
  20.             Dim writer As New System.IO.StreamWriter(req.GetRequestStream())
  21.             writer.WriteLine(Request)
  22.             writer.Close()
  23.             rsp = req.GetResponse()
  24.         Catch
  25.             Throw
  26.         Finally
  27.             If req IsNot Nothing Then
  28.                 req.GetRequestStream().Close()
  29.             End If
  30.             If rsp IsNot Nothing Then
  31.                 rsp.GetResponseStream().Close()
  32.             End If
  33.         End Try
I always get a 400 Bad Request error.  When I manually type in the url along with the xml data I can create tickets just fine.  Is there some way to add a record from code behind in .net?  I need a good example please!