Creating an Export

From API Documentation

Jump to: navigation, search

Use the Zuora Export object to conveniently query and access data that is joined with other objects.

  1. Create() an Export object, specifying which fields are to be in the Export.
  2. Specify the fields to be included with Export ZOQL (which differs slightly from the Z-Commerce API ZOQL):
 
<ns1:create xmlns:ns1="http://api.zuora.com/">
 <ns1:zObjects xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:Export">
     <ns2:format>csv</ns2:format>
     <ns2:name>My Export</ns2:name>
     <ns2:query>SELECT Account.Name, BillToContact.WorkEmail FROM Account</ns2:query>
     <ns2:Zip>True</ns2:Zip>
 </ns1:zObjects>
</ns1:create>
  1. This will return the Export.Id. Using this, Query for the status of the of the created Export: SELECT status, fileId FROM Export WHERE Id=Export.Id
  2. Once Status=Completed, using the REST API to retrieve the file based on Export.fileId.
  3. Use HTTP GET to the URL https://www.zuora.com/apps/file.do?id=FILE_ID (Zuora REST API) where FILE_ID is set to the Export.filedId. Use one of the following methods to gain access to this URL:
    • Using Basic Authentication and pass your Zuora username and password
    • Set a cookie in the request with a valid Zuora Session Id that you can get via login(). The cookie should be of the format: Cookie: ZSession=SESSION