Happy Business Starts Here

Accessing datasource via API

I would like to know the way to access various datasource from REST API. The URL, the way to pass filter criteria & the required fields selection.

 

 

Tags (2)
6 REPLIES 6
Support SME

Re: Accessing datasource via API

We can use "export" to get the result of query to data source and there is more detailed info about how to use it at:

https://www.zuora.com/developer/API-Reference/#tag/Exports

 

And here is a screenshot of a test I did for your reference:

Screen Shot 2017-03-24 at 12.42.51.png

 

Then you may use this ID to retrive the detailed result of the query which will include a FileID:

Screen Shot 2017-03-24 at 12.44.50.png

 

So we can use this FileId to retrieve the result file:

https://apisandbox.zuora.com/apps/file/2c92c0865af47d54015afe7617a03336






If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Re: Accessing datasource via API

@Yolanda Thank You so much. I appreciate that.

 

Instead of exporting to a file, is there a way to get the results of the query into response directly like how we get from the API https://rest.apisandbox.zuora.com/v1/action/query

 

Datasources are helping in a great manner to retrive the data by combing the tables but the same is not achievable through https://rest.apisandbox.zuora.com/v1/action/query as it is not supporting joins.

 

Many a times, we need to join the tables and retrive the result. Say, to update the price of a product - we may first need to get the Id of product and based on that ProductRatePlan Id and again ProductRatePlanCharge - ProductRatePlanChargeTier. If we have some solution like datasource then we may get the result in a single query

 

Thank You!

Master

Re: Accessing datasource via API

Have a look at what I did in https://github.com/bolaurent/zuora-restful-python/blob/master/zoql.py.

 

This is a command line tool that lets you query zuora. If there's a period character anywhere on the query, it interprets the query as a datasource export.

 

 

Highlighted

Re: Accessing datasource via API

Thank You @bolaurent How do I use this in my code?

Support SME

Re: Accessing datasource via API

Hello @irachamreddy the Data Source Export is an asynchronous job being executed and processed in the background, so unfortunately it's not possible to get the query results in a response. A complicated export can take significantly longer to process than a synchronous API call and the result can be hundreds of megabytes in size.

 

When you need to update a price on a Tier, I suggest simply creating an export on the Tier data source, joining the required tables' fields just like you've described, and using this result file to quickly grab the necessary IDs and values for your update calls.



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Master

Re: Accessing datasource via API

The link I provided is a complete solution, implemented in python. The method that wraps an export query can be told to block (wait until the export is ready) or not to block.

 

I can't tell you how to implement this in your own code, beause you haven't shared what language you are working in. The code I shared is pretty simple, and intended to provide an example of the logic needed; you can just borrow the code wholesale (if you are working in python) or you can use it as a hint for how to implement similar logic in your own code.

 

I'll second Viktor's suggestion that you may want to design your code to do the joins itself, avoiding the need for asynchrony.