Ruby on rails 我应该如何使用RubyonRails中的api在ZohoCRM中插入注释
我不知道如何使用api以xml格式发送数据Ruby on rails 我应该如何使用RubyonRails中的api在ZohoCRM中插入注释,ruby-on-rails,ruby,zoho,Ruby On Rails,Ruby,Zoho,我不知道如何使用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
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
您应该尝试使用Net/httplib
Zoho的API要求您发布XML数据 下面是一个使用
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
}
)
需要“httparty”
类ZohoCRM
包括HTTParty
结束
#生成的romzohoapi
认证令牌='1234567890ABCDEF'
#联系人(领导等)记录Id
实体id='123456700000000012345'
api_上下文='crmapi'
xml_data=“#{entity_id}Zoho CRM示例说明这是测试Zoho CRM API的示例内容”
response=ZohoCRM.post(
'https://crm.zoho.com/crm/private/xml/Notes/insertRecords',
正文:{
新格式:“1”,
authtoken:AUTH_令牌,
范围:api_上下文,
xmlData:xml_数据
}
)
引用:这意味着您必须检查zoho抛出此异常的情况。数据已发布,但还有一些其他问题。我只想知道如何发送xml数据,即使我可以通过curl发送数据,这也会对我有很大帮助