Запрос всех счетов с открытыми балансами с использованием QuickBooks Online (QBO) Intuit Partner Platform (IPP) DevKit

Я пытаюсь запросить все счета с открытыми балансами с использованием IPP, но я продолжаю получать 0 результатов обратно. Я делаю что-то не так в коде?

Вот мой фрагмент кода C #, который я пытаюсь сделать с помощью примененной фильтрации.

        InvoiceQuery qboInvoiceQuery = new InvoiceQuery();
        int iMaxPageNumber = QUERY_MAX_PAGE_NUMBER;   // A Constant with the Maximum Page Number allowed in a query 
        int iResultsPerPage = QUERY_MAX_NUM_PER_PAGE_INVOICE; // A Constant with the Maximum Results per page 

        // Paging Information
        qboInvoiceQuery.PageNumber = QUERY_START_PAGE_NUMBER;
        qboInvoiceQuery.ResultsPerPage = iResultsPerPage;

        #region Query Filtering
        //////////////////////////////////////////////
        //   initial filtering via Query Criteria   //
        //////////////////////////////////////////////
        // Get only Open (Unpaid) Invoices
        qboInvoiceQuery.OpenBalance = (decimal)0.00;
        qboInvoiceQuery.SpecifyOperatorOption(FilterProperty.OpenBalance, FilterOperatorType.AFTER);
        //////////////////////////////////////////////
        // END initial filtering via Query Criteria //
        //////////////////////////////////////////////
        #endregion

        // Complete the Query calls to build the list
        IEnumerable<Invoice> results = qboInvoiceQuery.ExecuteQuery<Invoice>(_ServiceContext);
        IEnumerable<Invoice> qboInvoices = results;
        int iCount = results.Count();
        while (iCount > 0 && iCount == iResultsPerPage && qboInvoiceQuery.PageNumber <= iMaxPageNumber)
        {
            qboInvoiceQuery.PageNumber++;
            results = qboInvoiceQuery.ExecuteQuery<Invoice>(_ServiceContext);
            iCount = results.Count();
            qboInvoices = qboInvoices.Concat(results);
        }

***ОБНОВИТЬ ***

Я реализовал ответ Петерла и теперь у меня есть следующий код. Однако сейчас я сталкиваюсь с новой проблемой, заключающейся в том, что мой код всегда возвращает 10 счетов по умолчанию и не учитывает мое тело. Даже если я установлю для него другой номер страницы или значение ResultsPerPage, мне вернутся первая страница и 10 результатов. Есть идеи?

    private Dictionary<string, Invoice> GetUnpaidInvoicesDictionary(IdType CustomerId, bool bById = true)
    {
        Dictionary<string, Invoice> dictionary = new Dictionary<string, Invoice>();
        int iMaxPageNumber = 100;
        int iResultsPerPage = 100;

        try
        {
            OAuthConsumerContext consumerContext = new OAuthConsumerContext
            {
                ConsumerKey = _sConsumerKey,
                SignatureMethod = SignatureMethod.HmacSha1,
                ConsumerSecret = _sConsumerSecret
            };

            string sBaseURL = "https://oauth.intuit.com/oauth/v1";
            string sUrlRequestToken = "/get_request_token";
            string sUrlAccessToken = "/get_access_token";
            OAuthSession oSession = new OAuthSession(consumerContext, 
                                                        sBaseURL + sUrlRequestToken,
                                                        sBaseURL,
                                                        sBaseURL + sUrlAccessToken);

            oSession.AccessToken = new TokenBase
            {
                Token = _sAccessToken,
                ConsumerKey = _sConsumerKey,
                TokenSecret = _sAccessTokenSecret
            };

            int iPageNumber = QUERY_START_PAGE_NUMBER;
            string sCustomerId = CustomerId.Value;
            string sBodyBase = "PageNum={0}&ResultsPerPage={1}&Filter=OpenBalance :GreaterThan: 0.00 :AND: CustomerId :EQUALS: {2}";
            string sBody = String.Format(sBodyBase, iPageNumber, iResultsPerPage, sCustomerId);

            IConsumerRequest conReq = oSession.Request();
            conReq = conReq.Post().WithRawContentType("application/x-www-form-urlencoded").WithRawContent(System.Text.Encoding.ASCII.GetBytes(sBody)); ;
            conReq = conReq.ForUrl(_DataService.ServiceContext.BaseUrl + "invoices/v2/" + _DataService.ServiceContext.RealmId);
            conReq = conReq.SignWithToken();



            // Complete the Query calls to build the list
            SearchResults searchResults = (SearchResults)_DataService.ServiceContext.Serializer.Deserialize<SearchResults>(conReq.ReadBody());
            IEnumerable<Invoice> results = ((Invoices)searchResults.CdmCollections).Invoice;
            IEnumerable<Invoice> qboInvoices = results;
            int iCount = searchResults.Count;
            while (iCount > 0 && iCount == iResultsPerPage && iPageNumber <= iMaxPageNumber)
            {
                iPageNumber++;

                sBody = String.Format(sBodyBase, iPageNumber, iResultsPerPage, sCustomerId);
                conReq = oSession.Request();
                conReq = conReq.Post().WithRawContentType("application/x-www-form-urlencoded").WithRawContent(System.Text.Encoding.ASCII.GetBytes(sBody)); ;
                conReq = conReq.ForUrl(_DataService.ServiceContext.BaseUrl + "invoices/v2/" + _DataService.ServiceContext.RealmId);
                conReq = conReq.SignWithToken();

                searchResults = (SearchResults)_DataService.ServiceContext.Serializer.Deserialize<SearchResults>(conReq.ReadBody());
                results = ((Invoices)searchResults.CdmCollections).Invoice;
                qboInvoices = qboInvoices.Concat(results);
                iCount = searchResults.Count;
            }

            if (bById)
                foreach (Invoice Inv in qboInvoices)
                    dictionary.Add(Inv.Id.Value, Inv);
            else
                foreach (Invoice Inv in qboInvoices)
                    dictionary.Add(Inv.Header.DocNumber, Inv);

            return dictionary;

        }
        catch (Exception)
        {

            return null;
        }
    }

* ОБНОВИТЬ *

Существует аналогичная проблема, связанная с новым тестером API. Это может быть связано с этой проблемой, и они в настоящее время изучают ее.

Переполнение стека: запросы QuickBooks Online с фильтром возвращают 401 каждый раз

Ответы на вопрос(1)

Ваш ответ на вопрос