0

我想从 Zuora 获取所有客户帐户。除了Exports REST API,是否有任何 API 可用于获取分页列表中的所有帐户?

4

2 回答 2

0

如果您不想使用数据查询或任何类似的基于队列的解决方案,请改用Zoql
注意!您需要知道您需要的 Account 对象中的所有字段,星号 ( select *) 在这里不起作用:

select Id, ParentId, AccountNumber, Name from Account

您还可以将自定义字段添加到您的选择中。每页最多可获得 200 条记录。

于 2020-04-09T11:10:40.000 回答
0

这是我用来获取收入发票的格式,使用此代码并更改端点

import pandas as pd

# Set the sleep time to 10 seconds
sleep = 10

# Zuora OAUTH token URL
token_url = "https://rest.apisandbox.zuora.com/oauth/token"

# URL for the DataQuery
query_url = "https://rest.apisandbox.zuora.com/query/jobs"

# OAUTH client_id & client_secret
client_id = 'your client id'
client_secret = 'your client secret'

# Set the grant type to client credential
token_data = {'grant_type': 'client_credentials'}

# Send the POST request for the OAUTH token
access_token_resp = requests.post(token_url, data=token_data,
                                      auth=(client_id, client_secret))

# Print the OAUTH token respose text
#print access_token_resp.text

# Parse the tokens as json data from the repsonse
tokens = access_token_resp.json()
#print "access token: " + tokens['access_token']

# Use the access token in future API calls & Add to the headers
query_job_headers = {'Content-Type':'application/json',
    'Authorization': 'Bearer ' + tokens['access_token']}

# JSON Data for our DataQuery
json_data = {
        "query": "select * from revenuescheduleiteminvoiceitem",
        "outputFormat": "JSON",
        "compression": "NONE",
        "retries": 3,
        "output": {
                "target": "s3"
        }
}

# Parse the JSON output
data = json.dumps(json_data)

# Send the POST request for the dataquery
query_job_resp = requests.post(query_url, data=data,
                                  headers=query_job_headers)
# Print the respose text
#print query_job_resp.text

# Check the Job Status

# 1) Parse the Query Job Response JSON data
query_job = query_job_resp.json()

# 2) Create the Job URL with the id from the response
query_job_url = query_url+'/'+query_job["data"]["id"]

# 3) Send the GETrequest to check on the status of the query
query_status_resp = requests.get(query_job_url, headers = query_job_headers)
#print query_status_resp.text

# Parse the status from teh response
query_status = query_status_resp.json()["data"]["queryStatus"]
#print ('query status:'+query_status)

# Loop until the status == completed
# Exit if there is an error
while (query_status != 'completed'): 
    time.sleep(sleep)
    query_status_resp = requests.get(query_job_url, headers = query_job_headers)
    #print query_status_resp.text
    query_status = query_status_resp.json()["data"]["queryStatus"]
    if (query_status == 'failed'):
        print ("query: "+query_status_resp.json()["data"]["query"]+' Failed!\n')
        exit(1)

# Query Job has completed
#print ('query status:'+query_status)


# Get the File URL
file_url = query_status_resp.json()["data"]["dataFile"]
print (file_url)```

于 2019-06-13T15:38:14.727 回答