How should I insert notes in zoho crm using api in ruby on rails

1k Views Asked by At

I don't know how to send data in xml format using an api.

http_post "https://crm.zoho.com/crm/private/xml/Notes/insertRecords?newFormat=1&authtoken=#{settings.api_token}&scope=crmapi&xmlData" do |req|
        req.headers['Content-Type'] = 'application/xml'
        req.body = {xmlData:{note:generate_note_content(ticket)}}.to_xml
      end
2

There are 2 best solutions below

1
On
0
On

Zoho's API requires that you POST the XML data.

Here is an example using the httparty gem:

require 'httparty'

class ZohoCRM
  include HTTParty
end

# Generated rom Zoho API
AUTH_TOKEN = '1234567890ABCDEF'

# The contact (lead, etc.) record Id 
entity_id = '1234567000000012345'
api_context = 'crmapi'
xml_data = "<Notes><row no='1'><FL val='entityId'>#{entity_id}</FL><FL val='Note Title'>Zoho CRM Sample Note</FL><FL val='Note Content'>This is sample content to test Zoho CRM API</FL></row></Notes>"

response = ZohoCRM.post(
  'https://crm.zoho.com/crm/private/xml/Notes/insertRecords',
  body: {
    newFormat: '1',
    authtoken: AUTH_TOKEN,
    scope: api_context,
    xmlData: xml_data
  }
)

Cite: https://www.zoho.com/crm/help/api/insertrecords.html#Insert_notes_and_relate_to_the_primary_module