How to Obtain the Accept-Language HTTP Header With IBM API Management
In this post I am going to explain how you obtain the client side HTTP Accept-Language setting for APIs built with IBM API Management on Bluemix and use the setting to determine the appropriate language to use in your API. I have created some sample code on IBM Jazz Hub that you can use as a basis for adding this capability to your own APIs.
When you are designing globalized APIs that are deployed using IBM API Management you need to take a few specific actions during the assembly step to ensure that the HTTP Accept-Language header field is properly forwarded to your implementing API.
By default IBM API Management does not forward and map all HTTP header fields to your underlying implementing API. To forward the Accept-Language field from the HTTP header perform the following steps:
Once you have the Accept-Language field being forwarded to your API you can compare that value with all the supported languages in your service. To help make the task of selecting the most appropriate language to use in your service you can use the accept-language Node.js package. In my example service I support three languages: English (en), French (fr), and Spanish (es) with the default being set to English.
I hope this helps you get started building globalized APIs with IBM API Management on Bluemix.
Tags: Bluemix, IBM API Management