Set Language/culture in API call

Vote:
 

Hi all

We have an API hosted on Optimizely 12, which we call from our Javascript frontend. In general it works just fine. However culture is not set correctly in our API Controller. When looking at Thread.CurrentThread.CurrentUICulture, we can see that culture is "en". We have not enabled "en" on our Optimizely site, but instead we have enabled "en-US" for different reasons.

How are you handling language and culture in your API calls?

I have found this thread in the forum, but as far as I can see, it never reached an answer:

https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2022/9/best-practice-for-fetching-language-context-in-an-api-controller/

It looks as if the Optimizely Content Delivery API relies on the Accept-Language header being set correctly. I think that is a good option, and we have tried to set this header in our API calls. It is not picked up automatically by our API Controller.

How do I programatically set language in a way that Optimizely accepts?

Thank you for your help.

Regards

Anders

#328324
Aug 29, 2024 6:36
Vote:
 

If I remeber correctly API:s typically run in a separate thread thus this issue.

I usually implement an ActionFilterAttribute fetching the language cookie that way, from there on you can set the thread cultures.

#328506
Aug 30, 2024 11:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.