Response Formats
Lgfapi supports JSON (default) and XML formats for data returned in the body of the response. This applies to all HTTP methods that return a response body.
The requester is able to specify the response format in several ways:
- Making a request without specifying the response format will result in the default JSON format.
- Using the reserved “format” query string parameter in the URI when making a request.
You can set the format to XML by adding “format=xml” to the query string portion of the request (the key-value pair data after the “?”). This is in addition to any other query string parameters also in the URI:
…/resource/?format=json
…/resource/?format=xml
Note – “format” is one of the few query string parameters you can use with HTTP methods like POST, which typically require all data to be in the body of the request.
- Using the file-extension dot-notation in the URI when making a request.
Very similar to the example above, you can also request the format using dot notation like you would when giving a file the extension “.xml” or “.json”:
…/resource/.json
…/resource.xml (optional trailing slash)
This can also be combined with a query string:
…/resource/.xml?key1=value1&key2=value2