Retrieving Properties of a Published Query

February 27 2014

Although I2E Queries and Multi Queries are binary objects, the I2E Web Services API provides an interface to a subset of the properties of those items, including some that can be modified when running a query programmatically.

Query properties that are read-only and that can be retrieved using the API include title, creator, comments and column headers. Query properties that can be modified before query submissions include number of hits, time limit and smart query parameters.

I2E has two, related, query resources: Saved Queries (that represent the binary files on disk, stored in the Repository) and Published Queries (that represent the Published location of the Saved Queries). To ensure that Users have permissions to see Query Properties, it is recommended that you only expose access to Published Queries.

Retrieving (by GET) a Published Query provides a “handle” to the Saved Query:

HTTP Header = X-Version: *, Accept: application/json GET http://i2e.company.com:8334/api;type=published_query/QueryTree/Query1.i2q Success 200

The response should look something like:

{
“shared”: true,
“valid”: true,
“handle”: “/api;type=saved_query/4.1/Query1.i2q”,
“error”: null,
“editable”: true
}

 

If you then retrieve that handle, you will receive an error because the server is trying to represent the query itself as JSON

HTTP Header = X-Version: *, Accept: application/json GET http://i2e.company.com:8334/api;type=saved_query/4.1/Query1.i2q Error 406
 

Note that if you do want to retrieve the query itself (rather than its properties) then change the format that you Accept to “application/octet-stream”:

HTTP Header = X-Version: *, Accept: application/octet-stream GET http://i2e.company.com:8334/api;type=saved_query/4.1/Query1.i2q Success 200
 

To get the query properties in a readable format, ask for the properties attribute of the saved query:

HTTP Header = X-Version: *, Accept: application/json GET http://i2e.company.com:8334/api;type=saved_query/4.1/Query1.i2q;attr=pro... Success 200
 

The start of the Query Properties should look something like this:

{
“smartQueryProperties”: {
“summary”: “This is a query summary”,
“creationDate”: “2013-10-04 21:01:17″,
“title”: “Query title”,
“privateComments”: “”,
“useInSmartQuery”: true,
“approxQueryTime”: “”,
“comments”: “Here are the query comments. These will be seen by users in I2E Express and I2E Pro”,
“creator”: “pbm”