Trying to make out this call
https://www.zoho.com/creator/help/api/rest-api/rest-api-edit-records.html
I did tried everything but seems i need basic knowledge. Can anyone give me directions what is wrong with my code
Public Sub updateRecord(ByVal ht As Hashtable, ByVal criteriaField As String)
Dim apiUrl As String = "https://creator.zoho.com/api/xml/write/apikey=xxxx"
Dim xmlStr As New System.Text.StringBuilder
Dim newvalue As New System.Text.StringBuilder
newvalue.AppendLine("<newvalues>")
xmlStr.Append("<ZohoCreator><applicationlist>")
xmlStr.Append("<application name=copy-of-ebay-inventory><formlist><form name=Ebay_Inventory>")
xmlStr.AppendLine("<update>")
xmlStr.AppendLine("<criteria>")
xmlStr.AppendLine("<field name='Ticket Number' compOperator='Equals' value='20573'></field>")
xmlStr.AppendLine("</criteria>")
newvalue.AppendLine("<field name='Found on site' value='1'></field>")
newvalue.AppendLine("</newvalues>")
xmlStr.Append(newvalue.ToString)
xmlStr.AppendLine("</update>")
xmlStr.AppendLine("</form></formlist></application></applicationlist></ZohoCreator>")
Dim params As String = "XMLString=" + xmlStr.ToString
Dim res As String = getResponseFromUrl(apiUrl, params)
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() = 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
At the end of formating my xml looks like
But that is not that. Found a good example on ..
Reposnse
Wrap all XML attribute values with a quote (single or double, although double is more common):
xmlStr.Append("<application name=" & ControlChars.Quote & "copy-of-ebay-inventory" & ControlChars.Quote &
"><formlist><form name=" & ControlChars.Quote & "Ebay_Inventory" & ControlChars.Quote & ">")