Hello,
I am struggling for one day and I hope someone can help me. I try to add a record from a windows forms application using vb.net. This is my code:
- Public Sub addRecord(ByVal ht As Hashtable)
- Dim apiUrl As String = "https://creator.zoho.com/api/<xxx>/xml/<appname>/form/<form name>/record/add/"
- Dim xmlStr As New System.Text.StringBuilder
- xmlStr.Append("<input type=""hidden"" name =""authtoken"" value=""abcdefghijk"">")
- xmlStr.Append("<input type=""hidden"" name =""scope"" id=""scope"" value=""creatorapi"">")
- Dim enu As IDictionaryEnumerator = ht.GetEnumerator
- While (enu.MoveNext)
- xmlStr.AppendLine("<input type=""text"" name=""" + enu.Key + """ value=""" + enu.Value + """>")
- End While
- Dim params As String = "XMLString=" + xmlStr.ToString
- Dim res As String = getResponseFromUrl(apiUrl, params)
- MsgBox(res)
- End Sub
-
- Public Function getResponseFromUrl(ByVal url As String, ByVal params As String)
- Dim str As String = ""
- Try
- Dim webreq As HttpWebRequest = WebRequest.Create(url)
- webreq.Method = "POST"
- webreq.ContentType = "application/x-www-form-urlencoded"
- Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes(params)
- Dim dataStream As Stream = webreq.GetRequestStream()
- dataStream.Write(byteArray, 0, byteArray.Length)
- dataStream.Close()
- Dim res As WebResponse = webreq.GetResponse()
- Dim stream As Stream = res.GetResponseStream()
- Dim streamReader As New StreamReader(stream)
- str = streamReader.ReadToEnd
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- Return str.ToString
- End Function
But I always get the error:
<response><errorlist><error><code>2899</code><message><![CDATA[Permission Denied To Add Record(s).]]></message></error></errorlist></response>
Any idea?
Thank you and kind regards,
Marco