0

我在 .NET 中工作,使用 QuickBooks V2 API 尝试获取用户 QBD 的项目数。

有没有人有一个工作示例来说明如何实现“RecordCountQuery”类来查找 QBD 中的项目数?

这是我这样做的尝试之一:

//
// Get a record count of the items
//
var qbItemsCount = new RecordCountQuery();

var myResults = qbItemsCount.ExecuteQuery<Item>(_oQBIDataServices.ServiceContext);

错误:

Intuit.Ipp.Exception.IdsException was unhandled by user code
  HResult=-2146233088
  Message= The RecordCountQuery xml must wrap an existing supported query object. Please modify your query and try again.
  Source=""
  ErrorCode=-2015

我由此得出结论,我应该在“ExecuteQuery”方法中使用不同的类型,例如 Intuit.Ipp.Data.QBD.ItemQuery。我试过这个,但得到了一个不同的错误。

所以我要求的不一定是对上述代码的更正,而是.NET 中 RecordCountQuery 类的工作示例。

谢谢你。

4

1 回答 1

2

编辑- 添加 .net 代码

RecordCountQuery query = new RecordCountQuery();
CustomerQuery custQuery = new CustomerQuery();
query.Item1 = custQuery;
List<RecordCount> customerRecordCountQuery = query.ExecuteQuery<RecordCount>(context).ToList();
string customerCount = customerRecordCountQuery[0].Count;

我有一个工作的java代码。请检查它是否有用。

API 端点 - https://services.intuit.com/sb/recordcount/v2/ {*relam_id*}

帖子正文

<RecordCountQuery xmlns="http://www.intuit.com/sb/cdm/v2">
    <CustomerQuery/>
</RecordCountQuery>

回复

<?xml version="1.0" encoding="UTF-8"?><!--XML GENERATED by IntuitDataSyncEngine (IDS) using \\SBDomainServices\CDM\branches\3.9.0-rel-1-->
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2"
xmlns:xdb          ="http://xmlns.oracle.com/xdb"
xmlns:xsi          ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation ="http://www.intuit.com/sb/cdm/v2 ../common/RestDataFilter.xsd"><RecordCounts>
<RecordCount>
<ObjectName>Customer</ObjectName>
<Count>392</Count>
</RecordCount>
</RecordCounts></RestResponse>

Java 代码

public int testGetCount() {
    int objectCount = 0;
    try {
        QBCustomerQuery CustomerQuery = QBObjectFactory.getQBObject(
                context, QBCustomerQuery.class);
        QBDRecordCountService iRecordCountSer = QBDServiceFactory
                .getService(context, QBDRecordCountService.class);
        List<QBRecordCountImpl> recordCounts = iRecordCountSer.getCount(
                context, CustomerQuery);
        Iterator<QBRecordCountImpl> iterator = recordCounts.iterator();
        while (iterator.hasNext()) {
            QBRecordCountImpl next = iterator.next();
            objectCount = Integer.parseInt(next.getCount().toString());
        }
        System.out.println("Customer count - " + objectCount);
    } catch (QBInvalidContextException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return objectCount;
}

谢谢

于 2013-08-19T13:44:53.130 回答