My zuora query command line utility does this for you; the code might be useful to look at, even if you are not writing python. See python-cmdline-zoql. The code snippet (from zuora_restful_python) is: def query_export(self, query):
export_id = self.create_export('temp.csv', query)
export_response = self.retrieve_export(export_id, block=True)
if export_response['Status'] != 'Completed':
return export_response
file_response = self.get_files(export_response['FileId'])
self.delete_export(export_id)
return file_response
... View more