Api options

The WCEA API comes with a few built in options that can be altered to suit your application's needs.

Most of the time, this is handled transparently by the SDK, however, this page shows some low-level features that can be accessed or modified.

Envelope

All responses from WCEA API come with an envelope, which contains meta information, such as Status and Count. This envelope can be turned off by sending ?envelope=false in the request URI.

Error suppression

When an error is encountered by the API, the usual behaviour is to return a HTTP error code in the response, and a payload containing more details about the error (See Errors).

However this behaviour can be turned off by sending ?suppress_response_codes=1 in the request URI.

If error codes are suppressed, all errors will return a 200 OK response header. However the response body will contain the error details.

Response type

By default, the API serves content in JSON. However it also supports XML and CSV responses.

XML responses can be turned on either by adding a ?type=xml in the query. Or by sending an Accept header with the value of application/xml.

CSV responses can be turned on either by adding a ?type=csv in the query. Or by sending an Accept header with the value of application/csv.

Please Note: Nested data cannot be converted into CSV, so endpoints that return nested data, will throw an error, when you try to access the data in CSV format.

Request data type

By default, the API expects POST and PUT data to be in multipart/form-data or multipart/x-www-form-urlencoded formats.

However, it can also accept JSON data if you send a Content-Type header with the value of application/json.

These options are usually handled transparently by the SDK, these examples just provide a low level overview of the said options.

Turn off Envelope

curl http://wceaapi.org/v1.1/user/999?envelope=false

Suppress Errors

curl http://wceaapi.org/v1.1/user/999?suppress_response_codes=1

Get XML responses

curl http://wceaapi.org/v1.1/user/999?type=xml
//--OR--
curl -H "Accept: application/xml" \
http://wceaapi.org/v1.1/user/999

Get CSV responses

curl http://wceaapi.org/v1.1/user/999?type=csv
//--OR--
curl -H "Accept: application/csv" \
http://wceaapi.org/v1.1/user/999

POST JSON payloads

curl -X POST \
     -H "Content-Type: application/json" \
     -d '{"name":"Bob","surname":"Smith"}' \
     http://wceaapi.org/v1.1/user/999