- Accept-Language
- Content-Type
- If-Modified-Since and If-Unmodified-Since (REST only)
- SO-TimeZone
Multiple languages
The API supports internationalization. A request without anAccept-Language header returns the string identifiers unchanged. Multi-language names are unchanged.
NO:"Leverandør";US:"Supplier" - which is not so useful when we want to show something to the user.
If we add the Accept-Language: en header, then we get back a parsed result:
Supplier.
Similarly, string resource IDs are replaced when a language is specified. This applies to some archive headings and entity properties.
Field properties contain reasons why fields are required. Without an Accept-Language header, you get back FieldProperties like this:
Accept-Language: fr header, we get back:
SO-Language
Sometimes the browser doesn’t want to change theAccept-Language it is using. We can override the Accept-Language header with the custom SO-Language header.
* or an x to signal you want to cancel language translation.
SO-Culture
Some cultures have variations in number formatting and so on. These can be handled using theSO-Culture header.
For the most part, dates and numbers are passed in neutral culture form. The JSON date is always going to be in ISO format 2019-09-23T12:34:45Z and a decimal number is always going to be with a period decimal point 3.14159.
But if an API returns a string containing a value "3.14159" rather than the value itself, the SO-Culture header will handle these for you.
SO-Culture defaults to the language, so you only need to specify it when it is different. The following tells the API to use the Norwegian strings and labels, but format numbers and dates as Swedish.
Content types
The API supports both JSON and XML responses. Use theAccept header to specify which you would like to receive.
XML
Agents:JSON
Agents:Modified or unmodified
These headers apply only to the REST WebAPI (not Agents).
If-Modified-Since
Returns HTTP code 304 Not Modified if the entity has not been modified since the given date+time on the GET request.GET /api/v1/Contact/123 always returns a contact object.
If-Unmodified-Since
Returns HTTP code 412 Precondition failed if the entity has been modified since the given date+time on the PUT update request.SO-TIMEZONE
You specify the time zone using theSO-TIMEZONE HTTP header. It can be either an ID or a time-zone name.
The following blocks are the same because the /api/v1/timezone archive lists the Norway time zone code as 261.
includeTZOffset
includeTZOffset to the SO-TIMEZONE header will cause the time zone offsets to be included in the JSON. This makes JavaScript adjust the dates to UTC correctly and will affect date-time calculations done by clients since the timezone is no longer unspecified.
For example: