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
objectIdsarray, otherwise setobjectIdsto a string value ofall. Set the accompanyingobjectTypetocpcode. -
Optionally specify an array of
metricswhosenamevalues you gathered earlier. Otherwise omitmetricsfrom the request to include all available metrics for this report. -
Optionally specify a map of
filterswhosenamevalues you gathered earlier. Otherwise omitfiltersfrom the request to generate unfiltered data. -
POST the object to
/reporting-api.
To run the Get a report GET operation:
-
Specify an
objectTypequery parameter ofcpcode. -
Specify an
objectIdsquery parameter with the set of CP codes you want to report on, separated with commas. Otherwise instead you can specify anallObjectIdsquery parameter to widen the scope of the report. Doing so may also shorten the URL. -
Specify a
metricsquery parameter, with the set of metricnamevalues you gathered earlier, separated with commas. -
Specify a
filtersquery parameter, with the set of filternamevalues 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 howfilterswould 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
Acceptheader totext/csv, application/problem+jsonfor CSV output with JSON error messaging.
The use of negative filters
Depending on the report type, negative filters, such as
url_not_start_withorurl_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.
