Knowledge Center

Knowledge Center > API > Aggregate Query API (AQuA) > Post Query

Post Query

This AQuA REST API submits an aggregated list of ZOQL and Export ZOQL queries.  

Request

POST https://www.zuora.com/apps/api/batch-query/

POST https://apisandbox.zuora.com/apps/api/batch-query/

Request Parameters

format

The supported values are csv, zip and gzip. The default value is csv.

version

The API version you want to use. Supported versions:

  • 1.2 Supports both modes
  • 1.1 Supports both modes
  • 1.0 Default. Supports Stateless mode only

See Stateless and Stateful Modes for more information.

name

The name of the job. 32 character limit.

encrypted

If enabled, you must supply the formatting (zip or unzip) first and decrypt it to get the actual contents.
Supported values are: pgp and none. 

useQueryLabels

When this optional flag is set to true the request will use object and field API names for the CSV header output instead of the field labels. Data integration projects should set useQueryLabels to true so that API names remain the same.

By default useQueryLabels is false, so that output CSV headers display the more user-friendly object and field labels. 

partner

The partner field indicates the unique ID of a data integration partner.

It must be used together with "project" field to uniquely identify a data integration target.  

For example, if a continuous AQuA session is to retrieve data incrementally for a

Salesforce.com Org 00170000011K3Ub, you can use partner as "Salesforce", and "project" as "00170000011K3Ub." 

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

Submit a request at Zuora Global Support to obtain a partner ID.

project

The project field contains the unique ID of a data integration project for a particular partner.  This field  must be used together with partner field to uniquely identify a data integration target.

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

dateTimeUtc

When using WSDL 69 and later you can ensure that the exported output of dateTime records are rendered according to ISO-8601 generic UTC form by setting dateTimeUtc to "true".

When "dateTimeUtc" is set to "true", exports of dateTime data types will be rendered in the following generic format: 
  YYYY-MM-DDThh:mm:ss-hhmm or 
  YYYY-MM-DDThh:mm:ss+hhmm  

NOTE: Regardless of what batchType query is used (zoql or zoqlexport), the query response output for datetime data types can be standardized by setting dateTimeUtc to true. When true, the results will display datetime types with the format: YYYY-MM-DDThh:mm:ss+/-hhmm.  

nullReplacement

The string used to represent null values in the query results. If you do not set this parameter, null values are represented by the empty string in the query results.

queries

A JSON Array object that contains a list of query objects. The list of query objects are name and query.

   name

The query name that can uniquely identify the query in this API request

   type

The query type. The supported values are zoql and zoqlexport.

   query

A ZOQL query or Export ZOQL query. Values can be zoql or zoqlexport.

apiVersion 

The API version for the query. If an API version is not specified, the latest version is used by default.  Using the latest WSDL version is most useful for reporting use cases. For integration purposes specify the WSDL version to ensure consistent query performance.  

As of API version 69 and later, Zuora changed the format of certain fields. See Date Field Changes in the SOAP API for more information and a list of affected fields.

convertToCurrencies

Optional. The currencies that you want to convert transaction amounts into. You can specify any number of currencies. Specify the currencies using their ISO currency codes and separate each currency with a comma, for example, "EUR,GBP,JPY".

See Convert Transaction Amounts Into Any Currency for more information and examples.

To use this field, you must have Foreign Currency Conversion enabled and you must be using API version 78 or later.

Response Parameters

Batches

A JSON array object that contains a list of batch objects.

name

Name of the query supplied in the request.

query

Name of the query supplied in the request.

status

The status of the batch execution:

  • pending: The query was validated and submitted to the query executor for processing.
  • executing: The query is being processed.
  • completed: The query was successfully executed.
  • aborted: The query execution failed.
  • cancelled: The query was not processed.

recordCount

The number of records included in the query output file.

apiVersion

The API version for the query. If an API version is not specified, the latest version is used by default.  Using the latest WSDL version is most useful for reporting use cases. For integration purposes specify the WSDL version to ensure consistent query performance.  

As of API version 69 and later, Zuora changed the format of certain fields. See Date Field Changes in the SOAP API for more information and a list of affected fields.

batchId

A 32-character ID of the query batch.

batchType

The kind of batch job being submitted. Possible values are zoql or zoqlexport.

project

The project field contains the unique ID of a data integration project for a particular partner.  This field  must be used together with partner field to uniquely identify a data integration target.

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

partner

The partner field indicates the unique ID of a data integration partner.

It must be used together with "project" field to uniquely identify a data integration target.  

For example, if a continuous AQuA session is to retrieve data incrementally for a

Salesforce.com Org 00170000011K3Ub, you can use partner as "Salesforce", and "project" as "00170000011K3Ub." 

This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.

Submit a request at Zuora Global Support to obtain a partner ID.

name

The name of the job. 32 character limit.

id

The job ID created for the AQuA API request. The job ID can be used for querying for the query status.
The ID exists only if the JSON request can be parsed and validated successfully. Otherwise, the job ID is null.

version

The API version you want to use. Supported versions:

  • 1.2 Supports both modes
  • 1.1 Supports both modes
  • 1.0 Default. Supports Stateless mode only

See Stateless and Stateful Modes for more information.

format

The supported values are csv, zip and gzip. The default value is csv.

status

The job status. Status types are:

  • Submitted: The job was successfully submitted upon successful validation of the JSON request.
  • Executing: The job is being processed.
  • Completed: The query was executed successfully. Click completed to download a gzip archive of the results.
  • Error: There are some validation errors in the JSON input, and the job ID will not be available.
  • Aborted: The execution stopped because one of the queries failed. Check the error code and error messages for more details.
  • Pending: The job is extracting data from the database.

encrypted

If enabled, you must supply the formatting (zip or unzip) first and decrypt it to get the actual contents.
Supported values are: pgp and none. 

Examples

HTTP request: 

POST https://www.zuora.com/apps/api/batch-query/

POST https://apisandbox.zuora.com/apps/api/batch-query/

JSON request:

{
"format" : "csv",
"version" : "1.1",
"name" : "Example",
"encrypted" : "none",
"useQueryLabels" : "true",
"partner" : "salesforce",
"project" : "00170000011K3Ub",
"dateTimeUtc" : "true",
"queries"  : [ {
    "name" : "AccountingPeriod",
    "query" : "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
    "type" : "zoqlexport"
  }]
}

JSON response (Full load):

{
    "batches": [
        {
            "full": true,
            "name": "AccountingPeriod",
            "query": "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
            "status": "pending",
            "recordCount": 0,
            "apiVersion": "60.0",
            "batchType": "zoqlexport",
            "batchId": "402881824835bb2a01483c19f7da0257"
        }
    ],
    "project": "00170000011K3Ub",
    "partner": "salesforce",
    "name": "Example",
    "id": "402881824835bb2a01483c19f7d70256",
    "version": "1.1",
    "format": "CSV",
    "status": "submitted",
    "encrypted": "none"
}

JSON request:

{
"format" : "csv",
"version" : "1.1",
"name" : "Example",
"encrypted" : "none",
"useQueryLabels" : "true",
"partner" : "salesforce",
"project" : "00170000011K3Ub",
"dateTimeUtc" : "true",
"queries"  : [ {
    "name" : "AccountingPeriod",
    "query" : "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
    "type" : "zoqlexport"
  }]
}

JSON response (Incremental load):

{
    "batches": [
        {
            "full": false,
            "name": "AccountingPeriod",
            "query": "select Id,StartDate,EndDate,FiscalYear,Name,Status from AccountingPeriod",
            "status": "pending",
            "recordCount": 0,
            "apiVersion": "60.0",
            "batchType": "zoqlexport",
            "batchId": "402881824835bb2a01483c1e678c025b"
        }
    ],
    "project": "00170000011K3Ub",
    "partner": "salesforce",
    "name": "Example",
    "id": "402881824835bb2a01483c1e678a025a",
    "version": "1.1",
    "format": "CSV",
    "status": "submitted",
    "encrypted": "none"
}

Curl request:

When processing a request through a curl shell script, you must enclose the field value in nested single double single quotes, such as Invoice.Status='"'Posted'"'

USER_NAME="ZUORA_API_USERNAME"
PASSWORD="PASSWORD"
BASE_URL="https://www.zuora.com/apps"

echo 
echo "============= Posting the Aqua Job ===========" 
echo 
curl -i -k -u $USER_NAME:$PASSWORD -H "Content-Type:application/json" -H "Accept:application/json" -d '
{
"format" : "csv", 
"version" : "1.1", 
"name" : "Example", 
"encrypted" : "none", 
"useQueryLabels" : "true",
"partner" : "salesforce", 
"project" : "00170000011K3Ub", 
"dateTimeUtc" : "true",
"queries" : [ { 
  "name" : "Invoice", 
  "query" : "select Invoice.Amount, Invoice.Balance, Invoice.InvoiceDate, Invoice.InvoiceNumber from Invoice where ( Invoice.Status='"'Posted'"')", 
  "type" : "zoqlexport" 
 }] 
} 
 ' -X POST $BASE_URL/api/batch-query/

Curl response:

HTTP/1.1 200 OK 
Content-Type: application/json 
Date: Fri, 05 Sep 2014 11:27:54 GMT 
Transfer-Encoding: chunked 
Connection: Keep-Alive
{ 
"batches" : [ { 
  "full" : true, 
  "name" : "Invoice", 
  "query" : "select Invoice.Amount, Invoice.Balance, Invoice.InvoiceDate, Invoice.InvoiceNumber from Invoice where ( Invoice.Status='"'Posted'"')", 
  "status" : "pending", 
  "recordCount" : 0, 
  "batchId" : "e20b07474841608a01484592147305d3", 
  "apiVersion" : "59.0", 
  "batchType" : "zoqlexport" } ], 
  "project" : "00170000011K3Ub", 
  "partner" : "salesforce", 
  "name" : "Example", 
  "id" : "e20b07474841608a01484592147005d2", 
  "version" : "1.1", 
  "format" : "CSV", 
  "status" : "submitted", 
  "encrypted" : "none" }
Last modified
23:10, 10 Nov 2016

Tags

Classifications

(not set)