通过 REST API c# 检索 Zoho 模块的所有内容
Retrieve all contents of Zoho module via REST API c#
我正在尝试从 Zoho 获取我的模块的全部内容到我们的本地服务器。 deluge 代码确实有效,因为它 returns 对我来说是通过 API 发送的数据。但是,一旦到达 API,它就为空。有什么想法吗?
下面是洪水代码:
// Create a map that holds the values of the new contact that needs to be created
evaluation_info = Map();
evaluation_info.put("BulkData",zoho.crm.getRecords("Publishers"));
data = Map();
data.put(evaluation_info);
response = invokeurl
[
url :"https://zohoapi.xxxxx.com/publisher/publish"
type :POST
parameters:data
connection:"zohowebapi"
];
info data; (data returns all the data from publishers)
这是我的ASP.NET核心restfulAPI。它确实 ping 它并创建了文件,但文件的内容为空。
Route("[controller]")]
[ApiController]
public class PublisherController : ControllerBase
{
[HttpGet("[action]"), HttpPost("[action]")]
public void Publish(string data)
{
(it's already null when it comes here. why?)
string JSONresult = JsonConvert.SerializeObject(data);
string path = @"C:\storage\journalytics_evaluationsv2.json";
using (var file = new StreamWriter(path, true))
{
file.WriteLine(JSONresult.ToString());
file.Close();
}
}
}
}
我错过了什么?谢谢
联系Zoho支持后,他提供的解决方案是循环遍历数据,以便从模块中获取所有内容(如果它们超过200条记录。提供的解决方案,实际上并不需要只要您在代码中将 ZOHO api 设置为您的帐户,洪水代码就不再存在。这是我的最终解决方案。此解决方案根本不可扩展。最好使用 BULK CSV。
// Our own ZohoAPI which lets us connect and authenticate etc. Yours may look slightly different
ZohoApi zohoApi = new ZohoApi();
zohoApi.Initialize();
ZCRMRestClient restClient = ZCRMRestClient.GetInstance();
var allMedicalJournals = new List<ZCRMRecord>();
for (int i = 1; i <= 30; i++)
{
List<ZCRMRecord> accountAccessRecords2 =
restClient.GetModuleInstance("Journals").SearchByCriteria("Tag:equals:MedicalSet", i, 200).BulkData.ToList();
foreach (var newData in accountAccessRecords2)
allMedicalJournals.Add(newData);
}
我正在尝试从 Zoho 获取我的模块的全部内容到我们的本地服务器。 deluge 代码确实有效,因为它 returns 对我来说是通过 API 发送的数据。但是,一旦到达 API,它就为空。有什么想法吗?
下面是洪水代码:
// Create a map that holds the values of the new contact that needs to be created
evaluation_info = Map();
evaluation_info.put("BulkData",zoho.crm.getRecords("Publishers"));
data = Map();
data.put(evaluation_info);
response = invokeurl
[
url :"https://zohoapi.xxxxx.com/publisher/publish"
type :POST
parameters:data
connection:"zohowebapi"
];
info data; (data returns all the data from publishers)
这是我的ASP.NET核心restfulAPI。它确实 ping 它并创建了文件,但文件的内容为空。
Route("[controller]")]
[ApiController]
public class PublisherController : ControllerBase
{
[HttpGet("[action]"), HttpPost("[action]")]
public void Publish(string data)
{
(it's already null when it comes here. why?)
string JSONresult = JsonConvert.SerializeObject(data);
string path = @"C:\storage\journalytics_evaluationsv2.json";
using (var file = new StreamWriter(path, true))
{
file.WriteLine(JSONresult.ToString());
file.Close();
}
}
}
}
我错过了什么?谢谢
联系Zoho支持后,他提供的解决方案是循环遍历数据,以便从模块中获取所有内容(如果它们超过200条记录。提供的解决方案,实际上并不需要只要您在代码中将 ZOHO api 设置为您的帐户,洪水代码就不再存在。这是我的最终解决方案。此解决方案根本不可扩展。最好使用 BULK CSV。
// Our own ZohoAPI which lets us connect and authenticate etc. Yours may look slightly different
ZohoApi zohoApi = new ZohoApi();
zohoApi.Initialize();
ZCRMRestClient restClient = ZCRMRestClient.GetInstance();
var allMedicalJournals = new List<ZCRMRecord>();
for (int i = 1; i <= 30; i++)
{
List<ZCRMRecord> accountAccessRecords2 =
restClient.GetModuleInstance("Journals").SearchByCriteria("Tag:equals:MedicalSet", i, 200).BulkData.ToList();
foreach (var newData in accountAccessRecords2)
allMedicalJournals.Add(newData);
}