Having a hard time with the formating of the XML and hoping someone can have a look at this code and let me know if they can help.
The code works fine for the getRecords, so all is well there, but with insertRecords I am getting a 4500 general error. I think it must have something to do with the xml perhaps. Probably some bonehead mistake on my part.
Any ideas would be highly appreciated. vb code below:
Private Sub btnConnectAPI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnectAPI.Click
Dim ticket As String = getZoHoTicketID()
Dim apiKey As String = "xxxxxxxxxx"
Dim xml As String = "<?xml version='1.0' encoding='UTF-8' ?>" + vbNewLine
xml += "<Leads>" + vbNewLine
xml += "<row no=""1"">" + vbNewLine
xml += "<FL val=""Company"">asp comapny</FL>" + vbNewLine
xml += "<FL val=""First Name"">robbie</FL>" + vbNewLine
xml += "<FL val=""Last Name"">Noonan</FL>" + vbNewLine
xml += "<FL val=""Email"">deuce4@nohwere.com</FL>" + vbNewLine
xml += "<FL val=""Phone"">4444444444</FL>" + vbNewLine
xml += "</row>" + vbNewLine
xml += "</Leads>" + vbNewLine
'URL Format: http://crm.zoho.com/crm/private/xml/Leads/insertRecords
'The parameters are:
'ticket: Ticket ID.
'apikey: API key of your Zoho CRM account.
'xmlData: This is an XML string and the format should be same as of getRecords in XML format of fetched records
'wfTrigger: Set value as true to trigger the workflow rule while inserting record into CRM account. By default, this parameter is false.
'duplicateCheck: Set value as true to check the duplicate records before inserting into CRM account. By default, this parameter is false.
'isApproval: By default, records are inserted directly . To keep the records in approval mode, set value as true. You can use this parameters for Leads, Contacts, and Cases module.
'
Dim targetURL As String = "http://crm.zoho.com/crm/private/xml/Leads/insertRecords" + _
"?apikey=" & apiKey & "&ticket=" & ticket & "&xmlData=" & xml
'this gets all leads:
'Dim targetURL As String = "http://crm.zoho.com/crm/private/xml/Leads/getRecords?apikey=" & apiKey & "&ticket=" & ticket
Dim request As HttpWebRequest
request = DirectCast(WebRequest.Create(targetURL), WebRequest)
request.Method = WebRequestMethods.Http.Post
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
oResponse.Close()
MsgBox(tmp.ToString)
End Sub
Writer is a powerful online word processor, designed for collaborative work.