The API provides two operations that allow you to execute reports in slightly different ways:
-
The Generate a report POST operation accepts a request with a query JSON object that specifies the report's criteria.
-
The Get a report GET operation specifies the same data using query parameters. Note that overly long URLs may fail to execute, in which case use you can run the POST operation instead.
Both POST and GET operations respond with the same report object.
To run the Generate a report POST operation:
-
Prepare a query object for the POST request.
-
Specify the list of CP codes as an
objectIds
array, otherwise setobjectIds
to a string value ofall
. Set the accompanyingobjectType
tocpcode
. -
Optionally specify an array of
metrics
whosename
values you gathered earlier. Otherwise omitmetrics
from the request to include all available metrics for this report. -
Optionally specify a map of
filters
whosename
values you gathered earlier. Otherwise omitfilters
from the request to generate unfiltered data. -
POST the object to
/reporting-api
.
To run the Get a report GET operation:
-
Specify an
objectType
query parameter ofcpcode
. -
Specify an
objectIds
query parameter with the set of CP codes you want to report on, separated with commas. Otherwise instead you can specify anallObjectIds
query parameter to widen the scope of the report. Doing so may also shorten the URL. -
Specify a
metrics
query parameter, with the set of metricname
values you gathered earlier, separated with commas. -
Specify a
filters
query parameter, with the set of filtername
values you gathered earlier, followed by=
and the corresponding value. Separate each name/value pair with commas. To represent more than one value, repeat the filter name. For example, this is howfilters
would appear prior to URL-encoding:filters=ip_version=ipv4,ip_version=ipv6,traffic_type=standard_secure
.
To get CSV data instead of JSON:
- When making either the POST or GET request described above, set the
Accept
header totext/csv, application/problem+json
for CSV output with JSON error messaging.
The use of negative filters
Depending on the report type, negative filters, such as
url_not_start_with
orurl_not_contain
, work in a different way. For certain reports, these filters use the OR logic, which means you can only use one filter value at a time. Otherwise, the filters may not work in the expected way. If this is the case, you can see this information in the report definition in Available reports.