0

I am trying to figure out how to read the results of the Quickbooks Online report service. Specifically I am trying to show the results from reportBS on a label and here is my code:

OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(dictionary["accessToken"]);
ServiceContext serviceContext = new ServiceContext(dictionary["realmId"], IntuitServicesType.QBO, oauthValidator);
serviceContext.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
serviceContext.IppConfiguration.MinorVersion.Qbo = "55";
ReportService reportService = new ReportService(serviceContext);
reportService.accounting_method = "Accrual";
reportService.start_date = "2020-01-01";
reportService.end_date = "2020-10-31";
reportService.summarize_column_by = "Month";

serviceContext.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;

ReportService defaultReportService1 = new ReportService(serviceContext);
string defaultReportName = "BalanceSheet";
Report reportBS = defaultReportService1.ExecuteReport(defaultReportName);

The result I get when I run my code and place reportBS on a label is Intuit.Ipp.Data.Report with nothing else.

D-G
  • 29
  • 1
  • 9

1 Answers1

0

You need to save the QBO report as JSON or XML string? As far as I know, converting a QBO report object to JSON or XML needs to be done manually. Here is a question that shows how it is done with a profit and loss report. (this is actually very similar to the text extraction method I outlined in the first place, only the result gets reassembled as XML/JSON in your case).

If you just want to pass the report to another system or store the report serialization could fit the bill.


Following this basic report example:

private static void PrintRows(StringBuilder reportText, Row[] rows, int[] maxColumnSize, int level)
{
    for (int rowIndex = 0; rowIndex < rows.Length; rowIndex++)
    {
        Row row = rows[rowIndex];
        //Get Row Header
        Header rowHeader = GetRowProperty(row, ItemsChoiceType1.Header);
        //Append Row Header
        if (rowHeader != null && rowHeader.ColData != null) { PrintColData(reportText, rowHeader.ColData, maxColumnSize, level); }
        //Get Row ColData
        ColData[] colData = GetRowProperty(row, ItemsChoiceType1.ColData);
        //Append ColData
        if (colData != null) { PrintColData(reportText, colData, maxColumnSize, level); }

        //Get Child Rows
        Rows childRows = GetRowProperty(row, ItemsChoiceType1.Rows);
        //Append Child Rows
        if (childRows != null) { PrintRows(reportText, childRows.Row, maxColumnSize, level + 1); }
        //Get Row Summary
        Summary rowSummary = GetRowProperty(row, ItemsChoiceType1.Summary);

        //Append Row Summary
        if (rowSummary != null && rowSummary.ColData != null) { PrintColData(reportText, rowSummary.ColData, maxColumnSize, level); }
    }
}
StringBuilder reportText = new StringBuilder();
//Determine Maxmimum Text Lengths to format Report
//int[] maximumColumnTextSize = GetMaximumColumnTextSize(report);
//Append Column Headers
//PrintColumnData(reportText, report.Columns, maximumColumnTextSize, 0);

PrintRows(reportText, report.Rows, maximumColumnTextSize, 1);
wp78de
  • 18,207
  • 7
  • 43
  • 71