Query bundling

Query bundling allows you to string multiple queries in one API call.

Restriction:
  • Query bundling is only available for JSON output

  • There can be at most 32 bundled queries per request.

String queries together in the url by including multiple query parameters. For example, query1query2queryAqueryFoo or whatever you would like to call them. The result contains multiple tables corresponding to your query parameters. The query parameter labels are also the keys to the corresponding result tables in the returned JSON object.

Transactions

By default, each query in a bundle is independent. If one of them fails, the others may still go through. The returned JSON response will inform the success/fail status of each one of the queries in the bundle.

When performing write statements, you might want to make two or more queries part of the same transaction, to ensure that they either all go through or they all fail. For example, you may want to issue one query that sets the alert status to closed, and another query that inserts a note about this in the note table. If for some reason one of these queries should fail, then it is better if the other one doesn't go through either.

This can be accomplished by putting both queries as part of the same bundle, and adding a parameter called 'transactions' to the request. Say the two queries queryA and queryB should be part of the same transaction, then add &transactions=queryA,queryB to the request. Multiple transactions can be specified by separating them with a pipe |, e.g. &transactions=queryA,queryB|queryC,queryD,queryE will specify that queryA and queryB form one transaction, and queryC, queryD and queryE form another (independent) transaction.

Sample Bundled Request

https://api.medallia.com/mainstreet?user=john&pass=Ypass12&query=SELECT count(*) FROM survey&queryFoo=select fullname, responsedate, br_overall_experience, br_likely_to_recommend from survey order by  responsedate desc limit 10&queryBar=select responsedate.year, distribution_value, dist(br_overall_experience), dist(br_likely_to_recommend), dist(br_likely_to_buy_next_prod) from  survey order by responsedate.year&version=1&output=json&apikey=5hxf4qz2qzjuxm46686csnwk

Sample result

Nozad","2006-12-30","1","10"],["Marden, Quon","2006-12-30","2","3"],["Gahagay, James Michelle","2006-12-30","10","10"],["Nieuwendijk, Cieplak","2006-12-30","7","10"],["Ewer, Soja","2006-12-30","7","10"],["Raster, Telka","2006-12-30","10","9"],["Kollhoff, Addel","2006-12-30","8","10"],["Hofstadter, Sergio Natalia","2006-12-30","5","6"],["Senuta, Tehmina","2006-12-30","6","10"],["Cabrerizo, Pavitt","2006-12-30","5","3"]]},"query":{"resultCode":0,"table":[["38999.0"]]},"queryBar":{"resultCode":0,"table":[["2005","1","750.0","240.0","707.0"],["2005","2","552.0","449.0","567.0"],["2005","3","850.0","551.0","893.0"],["2005","4","1233.0","847.0","1124.0"],["2005","5","1638.0","1183.0","1574.0"],["2005","6","1803.0","1524.0","1832.0"],["2005","7","2064.0","1831.0","2118.0"],["2005","8","2155.0","2087.0","2099.0"],["2005","9","2397.0","2075.0","2413.0"],["2005","10","6027.0","8682.0","6142.0"],["2006","1","685.0","228.0","714.0"],["2006","2","608.0","431.0","578.0"],["2006","3","886.0","582.0","882.0"],["2006","4","1234.0","820.0","1191.0"],["2006","5","1585.0","1189.0","1625.0"],["2006","6","1863.0","1575.0","1888.0"],["2006","7","2001.0","1838.0","2065.0"],["2006","8","2134.0","2028.0","2159.0"],["2006","9","2487.0","2149.0","2420.0"],["2006","10","6047.0","8690.0","6008.0"]]}}