Cisco Cisco Prime Performance Manager 1.5 Developer's Guide

Page of 41
 
Cisco Prime Performance Manager1.5 REST API Guide 
Monthly 
MONTH 
Last 1 year 
5  REST API Components 
5.1 Content-Type 
The reporting data provided by the REST API is formatted as text (XML, JSON, CSV), image (PNG,  
JPEG) or PDF. The data format type chosen for the responses is based on the outputType query string 
parameter or the value associated with the incoming HTTP Accept header. If no specific data type is 
found in the outputType query string parameter or the HTTP Accept Header is blank or */*, the REST 
API defaults the response format and content-type to “text/csv”. 
The outputType query string parameter has precedence over the HTTP Accept header. Therefore, 
when both the HTTP Accept header and the outputType query string parameter are found in the 
request, the response data type is based on the value defined in the outputType parameter. 
5.1.1 HTTP “Accept” Header 
The REST API implements the standard HTTP Accept header as specified in the Chapter 14.1 of the RFC 
2616, Hypertext Transfer Protocol – HTTP/1.1. When the outputType parameter is not found in the 
request, the REST API parses and processes the incoming HTTP Accept header q-factors values to 
determine the best acceptable media type for the response. 
Example of using the HTTP Accept header: 
Accept=text/csv;q=0.5,application/pdf?q=0.7,application/xml;q=0.9, 
application/vnd.cisco.ppm+json;v=2;q=0.95 
For the above HTTP Accept header, the media-range with the highest q-factor is: 
application/vnd.cisco.ppm+json;v=2 followed by application/xml, 
application/pdf, and text/csv. 
In this case, the REST API selects application/vnd.cisco.ppm+json;v=2 as the response 
format type which is the media-range with the highest q-factor. 
The Accept header “application/vnd.cisco.ppm+json;v=2” can be used to select the newer 
JSON format, which is simpler to traverse through the reporting data than the previous JSON version. 
This HTTP Accept header has the same effect as passing outputType=jsonv2 as a query string 
parameter. 
Note: a 406 status is returned for an Accept header that is not supported by the REST API. 
5.1.1.1 Accept Header Preference 
Ifthe Accept header contains multiple supported media types, the REST API uses the HTTP Accept 
header “q” (quality factor) to determine the preferred client media type, as explained above. However, if 
the supported media-types have the same q (quality factor) values, the REST API selects the media range 
using the following order of precedence: 
csv - > json - > xml - > png - > jpeg - > pdf  
For example, if the following HTTP Accept header is sent to the REST API: 
Accept=text/csv;q=0.5,application/pdf,application/xml