【问题标题】:How to get all accounts from API response? Zoho API C#如何从 API 响应中获取所有帐户? Zoho API C#
【发布时间】:2022-10-04 21:49:32
【问题描述】:

我现在遇到的问题是通过调用 ZohO GET 方法,然后我可以获得一次调用 - 200 个帐户,但是当我再次尝试调用时,我得到相同的 200 个帐户,我怎么能得到我所有的帐户?

我的代码:

        RecordOperations recordOperations = new RecordOperations();
        ParameterMap paramInstance = new ParameterMap();
        paramInstance.Add(GetRecordsParam.APPROVED, "both");
        paramInstance.Add(GetRecordsParam.SORT_ORDER, "asc");
        paramInstance.Add(GetRecordsParam.PAGE, 1);
        paramInstance.Add(GetRecordsParam.PAGE, 2);
        paramInstance.Add(GetRecordsParam.PER_PAGE, 200);
        paramInstance.Add(SearchRecordsParam.CRITERIA, "Account:equals:" + "Customer");
        paramInstance.Add(SearchRecordsParam.CRITERIA, "Account:equals:" + "Sub-customer");
        HeaderMap headerInstance = new HeaderMap();
        APIResponse<ResponseHandler> response = recordOperations.GetRecords(moduleAPIName, paramInstance, headerInstance);

        int totalAccounts = 0;
        if (response != null)
        {
                ResponseHandler responseHandler = response.Object;
                if (responseHandler is ResponseWrapper)
                {
                    //Get the received ResponseWrapper instance
                    ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                    List<Record> records = responseWrapper.Data;

                    foreach (Record record in records)
                    {
                        totalAccounts++;
                        ZohoAccount account = new ZohoAccount(record);
                        accounts.Add(account.Account_Name.ToString(), account);

                        object accountName = record.GetKeyValue("Account_Name");
                        accountNamez.Add(accountName);

                    }
                }
        }

我试图使用 for 循环,但我每次都得到相同的帐户。然后我试图这样说: 第一次调用:

        paramInstance.Add(GetRecordsParam.PAGE, 1);
        paramInstance.Add(GetRecordsParam.PAGE, 2);
        paramInstance.Add(GetRecordsParam.PER_PAGE, 200);

第二次调用:

        paramInstance.Add(GetRecordsParam.PAGE, 3);
        paramInstance.Add(GetRecordsParam.PAGE, 4);
        paramInstance.Add(GetRecordsParam.PER_PAGE, 200);

它也不起作用,所以问题不在页面上。

有谁知道如何调用其他帐户?

Zoho 文档 API: https://www.zoho.com/crm/developer/docs/csharp-sdk/v2/record-samples.html? 你可以找到:获取一个模块的所有记录。

【问题讨论】:

  • 为什么要设置参数 PAGE 两次?尝试为每个请求创建自己的“paramInstance”并设置 PAGE 一次。
  • @pakeha_by 因为通常每页有 100 个帐户,所以在第一次通话中我得到 200 个帐户,但下一个我得到完全相同的 200 个帐户,我试图弄清楚,但不要知道怎么做。

标签: c# api zoho


【解决方案1】:

我不确定它在 C# 中是如何工作的,但我为你的情况找到了这个: page 和 per_page 参数用于根据记录在 CRM 中的位置获取记录。假设用户必须获取 400 条记录。一个 API 调用最多可以获得 200 条记录。因此,对于第 200 位以上的记录,无法获取它们。通过使用 page (1 和 2) 和 per_page (200) 参数,用户可以使用 2 个 API 调用获取所有 400 条记录。

链接:https://www.zoho.com/crm/developer/docs/api/v3/get-related-records.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    • 1970-01-01
    • 2022-01-11
    • 2012-12-12
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    相关资源
    最近更新 更多