Forum Discussion

miikka's avatar
miikka
Maven
9 years ago

Updating user profile language through REST API v1 now broken

Hi,

we have been using this bit of code to change the language setting for a user:

<#assign update_lang_setting = rest("/users/self/profiles/name/language/set?value=${language}") />

This has worked well up until version 16.5 but now it seems to be broken or at least not working reliably enough (it's used in the page initialization script so it's hard to see what goes wrong).

 

So has something changed in 16.6 or in 16.7 which could cause this?

 

Cheers,

.M

  • ChiaraS's avatar
    ChiaraS
    Lithium Alumni (Retired)

    hi miikka

    don't think something changed around that. 

    I had a quick look at the logs and I see some messages like this, so maybe the problem is somewhere else in the common init logic:

     

    The following has evaluated to null or missing: ==> SUPPORTED_LANGUAGES_MAPPING[trimmedLang] [in template "language-detection.ftl" at line 44, column 29]

    Failed at: #local supportedLang = SUPPORTED_LANG... [in template "language-detection.ftl" in function "isLanguageSupported" at line 44, column 5] - Reached through: #local checkLang = isLanguageSupporte... [in template "language-detection.ftl" in function "getAcceptLanguage" at line 67, column 13] - Reached through: #assign lang = getAcceptLanguage(false) [in template "Common.init" at line 58, column 9]

     

     

    • miikka's avatar
      miikka
      Maven

      Thanks ChiaraS

       

      This specific error message is related to the same topic but applies only for anonymous users. And it's kind of expected as not all languages coming in browser settings are supported. But we can improve the logic so there won't be error messages like this in the log.

       

      Unfortunately the problem we have is related to authenticated users and that bit of code is not executed for them.

       

      Cheers,

      .M

      • ChiaraS's avatar
        ChiaraS
        Lithium Alumni (Retired)

        I see... I would try to use the user.id instead of self and use restadmin to see if it makes a difference:

         

        <#assign update_lang_setting = restadmin("/users/id/${user.id?c}/profiles/name/language/set?value=${language}") />