Executing Analytics Reports
The analyticsReportResults resource supports report execution in the REST API.
Use the POST method with the following syntax to execute Analytics reports:
https://your_site_interface/services/rest/connect/version/analyticsReportResults
Include the ID of the report you want to run and any filters (such as pagination) in the request body in JavaScript Object Notation (JSON) format.
Note:
- You can also use the LookupName of the report instead of its ID.
- Custom scripts don't run as part of report execution in the Connect REST API.
For related examples, see:
Example: ID
Using POST with the following URI:
https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults
and the following body:
{
"id": 27
}
executes the Analytics report with the ID number 27 and returns the following response:
{
"count": 1,
"name": "Last Updated by Status",
columnNames": [
"Status",
"Incidents",
"Average Time Since Last Response"
],
rows": [
[
"Unresolved",
"46",
null
]
],
"links": [
{
"rel": "self",
"href": "https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults"
},
{
"rel": "canonical",
"href": "https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults"
},
{
"rel": "describedby",
"href": "https://mysite.example.com/services/rest/connect/v1.4/metadata-catalog/analyticsReportResults",
"mediaType": "application/schema+json"
}
]
}
Example: LookupName
This example uses the LookupName of the report instead of its ID.
A POST operation with the following URI:
https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults
and the following body:
{
"lookupName": "Last Updated by Status"
}
executes the same report as in Example: ID.
Example: Pagination
This example uses pagination to limit the number of results returned.
A POST operation with the following URI:
https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults
and the following body:
{
"id":124,
"limit":25
}
returns the first 25 rows of the report. For more information, see Paginating.
Example: Filtering
You can also filter the results.
A POST operation with the following URI:
https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults
and the following body:
{
"id": 124,
"filters": [{
"name": "Name",
"values": "Chapman"
}]
}
returns the contacts whose names include Chapman:
{
"count": 2,
"name": "Contacts",
"columnNames": [
"Last Name",
"First Name",
"Email",
"Office Phone",
"Disabled",
"# Incidents"
],
"rows": [
[
"Chapman",
"Frederick",
"frederick.chapman@example.com",
null,
"No",
"0"
],
[
"Chapman",
"Kathleen",
"kathleen.chapman@example.com",
null,
"No",
"1"
]
],
"links": [
{
"rel": "self",
"href": "https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults"
},
{
"rel": "canonical",
"href": "https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults"
},
{
"rel": "describedby",
"href": "https://mysite.example.com/services/rest/connect/v1.4/metadata-catalog/analyticsReportResults",
"mediaType": "application/schema+json"
}
]
}
Example: UTC Time
In the November 2016 release, you can display times in reports in Coordinated Universal Time (UTC) format. The OSvC-CREST-Time-UTC
header, when set to true
or yes
, causes times to be displayed in UTC in reports. When the header is set to false
or no
, or isn't present, times are displayed in the time zone of the Oracle Service Cloud server. The default value is false
.
Note:
The value of OSvC-CREST-Time-UTC isn't case sensitive.For example, a POST operation with the following URI:
https://mysite.example.com/services/rest/connect/v1.4/analyticsReportResults
and the following body:
{
"lookupName": "SLA Milestones By Incident"
}
with no OSvC-CREST-Time-UTC header, gives the following results:
{
"count": 7,
"name": "SLA Milestones By Incident",
"columnNames": [
"milestone_instances.i_id",
"Milestone Name",
"Resolution Due"
],
"rows": [
[
"33",
"Resolution Due",
"'2015-09-15 16:00:00'"
],
[
"34",
"Resolution Due",
"'2015-12-23 10:03:00'"
],
[
"35",
"Resolution Due",
"'2016-06-09 16:00:00'"
],
...
Using the same request and body, but with the OSvC-CREST-Time-UTC header set to yes
, gives the following results:
{
"count": 7,
"name": "SLA Milestones By Incident",
"columnNames": [
"milestone_instances.i_id",
"Milestone Name",
"Resolution Due"
],
"rows": [
[
"33",
"Resolution Due",
"2015-09-15T23:00:00.000Z"
],
[
"34",
"Resolution Due",
"2015-12-23T18:03:00.000Z"
],
[
"35",
"Resolution Due",
"2016-06-09T23:00:00.000Z"
],
...
The times are now displayed in UTC format.