Response Formats

Overview

Live API Creator supports several response format types, beside the default JSON, configured globally from the API Properties > Settings tab. Described on this page are the formats currently implemented (CSV, XML 1.0, vanilla JSON, & a special JSON object format), how to conditionally or globally output a format, and the additional parameterization that API Creator supplies for them. Support for accepted request formats is described elsewhere in our documentation. 

REST Lab

It is possible to demo response formats in the REST Lab, by checking the "args" input near the "URL" text field. It will reveal a section of parameters, one of which is "Response Format". Listed in the dropdown are all the response types Creator supports.






Supported Response Formats

 CSV Comma separated values, each record is separated by a line end. Resources are flattened out to the topmost level.
 JSON JSON is a ubiquitous format on the web, and the default output of API Server
 JSON Object The object format for JSON changes the hierarchy of the data returned, putting the returned records in a nested "data" attribute
 XML Support for XML 1.0 was added in v2.1, restructuring metadata into XML tag attributes


Configuration & Parameterization

API Creator provides several entry points for describing the expected response format. To change it globally across an API, navigate to the API Properties page, and in the "Settings" tab, update the "Default Response Format" value.

It is possible to override the API default settings on a per request basis, by either passing in a HTTP Header: "X-CALiveAPICreator-ResponseFormat" or defining the URL variable "responseformat".
When conditionally requesting CSV, for example, a user might define it as such:
 HTTP Header     X-CALiveAPICreator-ResponseFormat: csv
 URL Variable    https://lapicbaseurl.com/rest/default/api-url-fragment/v1/main:table?responseformat=csv

It is possible to have the header and url variable defined, the priority from least to greatest is as follows: API default setting, HTTP header, URL variable.

The XML & CSV formats also support an additional URL variable: "nometa", which will optionally remove the metadata attributes (and for XML, the raw-name attribute for column values).
Comments