Language and Locale

If your knowledge base is available in multiple locales, you can control the locale of your API responses to meet your business requirements.

For resources available in multiple locales, you can use one of the following options to specify the locale. The options listed are in the order of decreasing precedence.
  • q query (see Supported Query Parameters)

    Note:

    This option is applicable only to the Content resource.
  • localeId + localeOverride=true (see Custom HTTP Headers)
  • langpref (querystring)
  • localeId alone (see Custom HTTP Headers)
  • User's preferred knowledge locale, if locale is not specified anywhere in the request and there's a user associated to the API request through the Authentication header that has a preferred knowledge locale.
  • Default locale, if locale is not specified anywhere in the request and the request is anonymous or the user has no preferred knowledge locale. Using the default locale is best if you have only one locale.

For example, the following URI returns a collection of content in Spanish (Spain) locale:

GET http://<IM_REST_API_HOST>/km/api/latest/content?langpref=es_ES

However, if you include the following kmauthtoken header with the localId and localeOverride parameters, the response has content in Swedish, because of higher precedence.

{"interfaceId":"1","localeId":"sv_SE","localeOverride": true}

For more information about language and locale in Knowledge, review the Implement Locales chapter of the Implementing Knowledge Management guide.

Specifying Locale: Examples

The following examples show the several ways in which you can specify the locale in your request to find all the Spanish (Spain) content record objects from the Oracle Knowledge repository.
  • curl -X GET "https://<IM_REST_API_HOST>/km/api/latest/content" -u "<username:password>" -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'kmauthtoken: {"localeId":"es_ES","localeOverride":true,"interfaceId":"1"}'
  • curl -X GET "https://<IM_REST_API_HOST>/km/api/latest/content?langpref=es_ES" -u "<username:password>" -H 'Accept: application/json' -H 'Content-Type: application/json'
  • curl -X GET "https://<IM_REST_API_HOST>/km/api/latest/content" -u "<username:password>" -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'kmauthtoken: {"localeId":"es_ES","interfaceId":"1"}'