Response Formats

Response Formats
lac52
This article includes information about response formats in 
Layer7 Live API Creator
.
In this article:
 
 
Demo Response Formats in the REST Lab
  1. With your API open, in the Tools section, click 
    REST Lab
    .
    The Request tab displays by default.
    For more information about how to use the REST Lab, see Test Using the REST Lab.
  2. Select the 
    Args
     checkbox.
    A section of parameters is revealed. The following image shows the 
    Args
     checkbox selected and the expanded section of parameters:
    Screen Shot 2016-12-02 at 10.53.39 PM.png
    For more information about how to view the filtering and ordering section of the page using the 
    Args
     checkbox, see GET.
  3. Choose a response format from the 
    Response Format
     drop-down.
    Options:
     
    • omit.
       Clears the selection and the default is used. 
    • json. 
      (Default) JSON is a ubiquitous format on the web and the default output of API Server. 
    • jsonObject.
       The object format for JSON changes the hierarchy of the data returned, putting the returned records in a nested "data" attribute.
    • xml.
       Restructures metadata into XML tag attributes.
    • csv.
       Comma-separated values (CSV), where each record is separated by a line end.  
      Layer7 Live API Creator
       flattens out the resources to the top-most level.
 
Default:
 json
Globally Describe the Expected Response Format
You can set the expected response format globally across an API using the 
Default response format
 field.
For more information about this API property setting, see API Properties.
Override the API Default Response Format Settings
You can override the API default response format settings on a per-request basis by passing in an 
X-CALiveAPICreator-ResponseFormat
 HTTP Header or by defining the 
responseformat
 URL variable. When conditionally requesting CSV formats, for example, an API user might define the request as:
HTTP Header
URL Variable
 
X-CALiveAPICreator-ResponseFormat: csv
 
https://lapicbaseurl.com/rest/default/api-url-fragment/v1/main:table?responseformat=csv
You can have the header and URL variable defined, the priority from least to greatest, such as API default setting, HTTP header, and URL variable.
For more information about the HTTP headers that you can specify, see HTTP Headers.
Remove Metadata Attributes
You can remove the metadata attributes for CSV formats, or for XML formats, the 
raw-name
 attribute for column values, using the 
nometa
 URL variable, for example:
nometa=true