REST API - executeGenericQuery

The table summarizes the REST API - executeGenericQuery.

Request

Format
POST <baseurl>/audit/query/execute
Query parameters
  • target=string (optional: default=AUDIT): Target of the query. This determines the Event Collector database table that is queried, which determines the attributes that can be used in your query and those that can be returned.

    For a list of the valid targets, including information about which Event Collector database tables each target value queries, see Using Attributes in Query Filters.

  • requireallattributes=string (optional, default=false): If true, returns all attributes in the response. If false, no attributes are returned (although information such as total number of items, and the start and end position, is returned). Use requiredattribute to return specific attributes.
  • requiredattribute=string (0-n): The attributes to be returned in the response. You can pass this parameter multiple times to return multiple attributes (see Example 3 below).
  • sortorder=string (0-n, optional): The attribute or attributes the results should be sorted on, and in what direction the sort should run. Specify this in the following format:

    attribute 1:ASCENDING|DESCENDING;attribute 2:ASCENDING|DESCENDING; … attribute n:ASCENDING|DESCENDING

  • correlate=string (optional, default=false) : Whether the query should be correlated.
  • gettotalcount=string (optional, default=true): If true, the total number of items that satisfy the query are returned in totalItems. If false, -1 is returned in totalItems.
  • numberofitems=integer (optional, default=-1): The number of items to return in the response. A value of -1 means return all responses.
  • populateattributenames=string (optional, default=true): If true, the name of each attribute returned is included in the response. If false, the attribute names are not returned; other information about the attribute is returned, such as type and value.
  • startposition=integer (optional, default=-1): The position in the list that resulted from the query from which to start the page of results. To start at the first item, specify 0 or -1.
  • parameters=string (optional, default=blank): Names and values of query parameters.
  • advancedoptions=string (not used)
Body executeQueryObject (mandatory).

Response

JSON Returns a JSON representation of the content of a GenericResult element.
XML Returns the content of a GenericResult element (from the EventCollectorQueryService schema).

Example 1

This example queries the ec_event Event Collector database view (target=AUDIT), and returns all attributes for all of the events associated with Clint Hill for the CSCallbackProcess.

Request
POST <baseurl>/audit/query/execute?target=AUDIT&requireallattributes=true
Request body
{
  "executeQueryObject": {
    "query": { "filter": "principalName='Clint Hill' AND messageCategory='PROCESS_INSTANCE' AND managedObjectName='CSCallbackProcess'" }
  }
}
Response
{
    "xml-fragment":
    {
        "endPosition": 55,
        "startPosition": 0,
        "totalItems": 55,
        "resultEntry":
        [
            {
                "id": 2270,
                "ref": "BX_INSTANCE_PROCESS_STARTED",
                "attribute":
                [
                    {
                        "@type": "base:DateEntryAttribute",
                        "attributeId": 20,
                        "attributeName": "creationTime",
                        "type": "DATE",
                        "value": "2017-09-05T20:40:32.427Z"
                    },
                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 1,
                        "attributeName": "messageId",
                        "type": "STRING",
                        "value": "BX_INSTANCE_PROCESS_STARTED"
                    },
                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 65,
                        "attributeName": "managedObjectName",
                        "type": "STRING",
                        "value": "CSCallbackProcess"
                    },
                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 160,
                        "attributeName": "processPriority",
                        "type": "STRING",
                        "value": "NORMAL"
                    },
.
.
.

                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 31,
                        "attributeName": "nodeName",
                        "type": "STRING",
                        "value": "BPMNode"
                    },
                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 21,
                        "attributeName": "hostName",
                        "type": "STRING",
                        "value": "techpubs-bpm"
                    },
                    {
                        "@type": "base:StringEntryAttribute",
                        "attributeId": 3,
                        "attributeName": "environmentName",
                        "type": "STRING",
                        "value": "BPMEnvironment"
                    }
                ]
            }
        ]
    }
}

Example 2

This example queries the ec_pe_status Event Collector database table (target=PROCESS_STATS) and returns the time (in the startTime attribute) that all instances of the CSCallbackProcess template were started.

Request
POST <baseurl>/audit/query/execute?target=PROCESS_STATS&requiredattribute=startTime
Request body
{
  "executeQueryObject": {
    "query": { "filter": "processTemplateName='CSCallbackProcess'" }
  }
}
Response
{
    "xml-fragment":
    {
        "endPosition": 11,
        "startPosition": 0,
        "totalItems": 11,
        "resultEntry":
        [
            {
                "id": -1,
                "attribute":
                {
                    "@type": "base:DateEntryAttribute",
                    "attributeId": -1,
                    "attributeName": "startTime",
                    "type": "DATE",
                    "value": "2017-10-31T13:44:22.657Z"
                }
            },
            {
                "id": -1,
                "attribute":
                {
                    "@type": "base:DateEntryAttribute",
                    "attributeId": -1,
                    "attributeName": "startTime",
                    "type": "DATE",
                    "value": "2017-10-31T13:53:09.177Z"
                }
            },
.
.
.
            {
                "id": -1,
                "attribute":
                {
                    "@type": "base:DateEntryAttribute",
                    "attributeId": -1,
                    "attributeName": "startTime",
                    "type": "DATE",
                    "value": "2017-09-05T21:27:35.900Z"
                }
            }
        ]
    }
}

Example 3

This example queries the ec_wi_status Event Collector database table (target=WORKITEM_STATS) and returns the ref and firstOfferTime attributes for all work items with a priority of 50 that were last opened by Clint Hill on Nov. 2, 2017.

Request
POST <baseurl>/audit/query/execute?target=WORKITEM_STATS&requiredattribute=ref&requiredattribute=firstOfferTime
Request body
{
  "executeQueryObject": {
    "query": { "filter": "priority=50 AND lastOpenTime=2017-11-02 AND userId='Clint Hill'"}
  }
}
Response
{
        "xml-fragment":
        {
            "endPosition": 3,
            "startPosition": 0,
            "totalItems": 3,
            "resultEntry":
            [
                {
                    "id": -1,
                    "attribute":
                    [
                        {
                            "@type": "base:LongEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "ref",
                            "type": "LONG",
                            "value": 57
                        },
                        {
                            "@type": "base:DateEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "firstOfferTime",
                            "type": "DATE",
                            "value": "2017-09-05T20:42:15.467Z"
                        }
                    ]
                },
                {
                    "id": -1,
                    "attribute":
                    [
                        {
                            "@type": "base:LongEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "ref",
                            "type": "LONG",
                            "value": 67
                        },
                        {
                            "@type": "base:DateEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "firstOfferTime",
                            "type": "DATE",
                            "value": "2017-09-05T21:27:36.167Z"
                        }
                    ]
                },
                {
                    "id": -1,
                    "attribute":
                    [
                        {
                            "@type": "base:LongEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "ref",
                            "type": "LONG",
                            "value": 69
                        },
                        {
                            "@type": "base:DateEntryAttribute",
                            "attributeId": -1,
                            "attributeName": "firstOfferTime",
                            "type": "DATE",
                            "value": "2017-09-05T21:33:52.297Z"
                        }
                    ]
                }
            ]
        }
    }