通过 Zuora REST 执行 ZOQL API

ZOQL Execution via Zuora REST API

我正在尝试通过 Zuora REST 执行一些 ZOQL API。

我参考了 this 文档并且我正在使用 REST 端点 v1/action/query 来执行 ZOQL。

首先我尝试了非常简单的请求并得到了结果

{
  "queryString": "select AccountId, FirstName, LastName from contact"
}

现在我尝试使用星号进行查询,如下所示

{
  "queryString": "select * from contact"
}

但是我遇到了以下错误

{
  "faultcode": "fns:MALFORMED_QUERY",
  "faultstring": "You have an error in your ZOQL syntax",
  "detail": {
    "MalformedQueryFault": {
      "FaultCode": "MALFORMED_QUERY",
      "FaultMessage": "You have an error in your ZOQL syntax"
    }
  }
}

here,我发现ZOQL支持asterisk。对于涉及多个对象的 ZOQL,我什至遇到了同样的错误。喜欢

SELECT Subscription.Name, Account.Name FROM Subscription WHERE Subscription.Status='Active' AND DefaultPaymentMethod.CreditCardType='Visa'

编辑 以上查询在 Zuora SOAP 中也不起作用 API

如何在 Zuora REST API 或 Zuora SOAP API 中使用星号执行查询?

在 ZOQL 中使用 Asterix 查询:

简而言之:你不能使用 asterix。

更多信息:

来自祖睿KnowledgeCenter:

No Wild Card Support

You cannot use the asterisk wild card (*) for field names with a query() call. You must explicitly specify a field name.

以上source you mentioned stating that you can use asterix, is NOT about ZOQL, but about Export ZOQL.

Export ZOQL is different from ZOQ, as stated in the docs 以上:

Zuora Export ZOQL (Zuora Object Query Language) is the query language used to create Exports with the Export object in the Zuora SOAP API. Zuora Export ZOQL is similar to our general ZOQL, with a few differences. The biggest difference is that with Exports, you query a Zuora data source, not a SOAP API object.

希望对您有所帮助。

祝你好运!

当您在查询中使用 * 是因为:

1) 您希望所有字段都可用

2) 您想了解哪些字段可用。

对于后一种情况,使用 REST 服务的 Describe 函数,如下所示:

https://{servicename}.zuora.com:####/v1/describe/Invoice

这将 return 发票(或任何其他)对象的 XML 描述为:

<?xml version="1.0" encoding="UTF-8"?>
<object href="https://services470.zuora.com/apps/api/describe/Invoice">
    <name>Invoice</name>
    <label>Invoice</label>
    <fields>
        <field>
            <name>AccountId</name>
            <label>Account ID</label>
            <selectable>true</selectable>
            <createable>true</createable>
            <updateable>false</updateable>
            <filterable>true</filterable>
            <custom>false</custom>
            <maxlength></maxlength>
            <required>true</required>
            <type>text</type>
            <contexts>
                <context>soap</context>
            </contexts>
        </field>
        <field>
            <name>AdjustmentAmount</name>
            <label>Adjustment Amount</label>
            <selectable>true</selectable>
            <createable>false</createable>
            <updateable>false</updateable>
            <filterable>true</filterable>
            <custom>false</custom>
            <maxlength></maxlength>
            <required>true</required>
            <type>decimal</type>
            <contexts>
                <context>soap</context>
                <context>export</context>
            </contexts>
        </field>
    <!-- All fields for Invoice...ETC   -->
</fields>
</object>