Requesting, headers and encoding (and version)
Most endpoints support both GET and POST.
You may specify the encoding the API should use to return data.
The header to use is "Accept" and must contains a version information.
Accept: application/json;version=0
(version must be present, but is usualy reserved for the futur, therefore, some endpoints like SMS functions require another value, in that case, this is documented)
Available encoders are:
Encoding | Comment |
---|---|
JSON | Available |
XML | Available |
YAML | partialy implemented, nested dictionaries can have issues |
TEXT | partialy implemented, nested dictionaries can have issues |
HTML | not always available, exists for user comfort, but not really usable as an API |
Here is an example of a query with good headers:
% curl -H 'Accept: application/json;version=0' 'https://api.ubity.com/call?key=KKKK&exten=EEE&number=NNN'
{
"api_call_uuid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"api_key": "KKKK",
"code": 200,
"diagnostic": "Success",
"mode": "normal",
"stamp": "2018-02-06 10:10",
"url": "https://api.ubity.com/call?key=KKKK&exten=EEE&number=NNN",
"version": 0
}
-
For historical reason and compatibility concerns, some endpoints does not have a consistant encoding when used without specifying headers. This is called the legacy behaviour, it's not supported nor documented, please don't use it (anymore) it can be removed at any moment. So, it's strongly recommended to always request using the headers (encoding and version). ↩