-1

我不知道如何使用 api 以 xml 格式发送数据。

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
4

2 回答 2

1

Zoho 的 API 要求您发布 XML 数据。

下面是一个使用httpartygem 的例子:

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
  }
)

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

于 2014-12-21T14:33:02.960 回答
0

您应该尝试使用 Net/http 库。

http://ruby-doc.org/stdlib-2.0.0/libdoc/net/http/rdoc/Net/HTTP/Post.html

于 2013-09-12T07:00:58.260 回答