Forum Discussion

micha80's avatar
micha80
Expert
10 years ago

Could not save profile value with REST API

Hi,

 

I want to save a profile variable with a new value using the rest api. I checked the normal form names and values and recreated a custom settings area.

 

I could read the most values with the rest api call: /users/self/profiles?restapi.response_style=json

 

Then i checked the form select option values and build my own page with form elements and the exact same option values:

 

For example:

<select class="lia-form-boardDistributionFrequency-input" name="boardDistributionFrequency" id="boardDistributionFrequency" data-key="board.sub_email_delivery_freq">
<option title="Nie" value="never">Nie</option>
<option title="Sofort" value="immediate">Sofort</option>
<option title="In einer Tagesübersicht" value="daily" selected="">In einer Tagesübersicht</option>
<option title="In einer Wochenübersicht" value="weekly">In einer Wochenübersicht</option>
</select>

 

So far so good. But when I choose "Nie" which sends "never" I could not save the value. Every other values is working fine. So when I choose "Sofort" which means "immediate" everything is ok. Only "never" produces an error 503. I am doing the following call which produces the error: /users/self/profiles/name/board.sub_email_delivery_freq/set?value=never

 

This request works fine: /users/self/profiles/name/board.sub_email_delivery_freq/set?value=immediate

 

Could someone explain what I am doing wrong?

 

 

Regards,

Michael

8 Replies

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    micha80 

     

    It shouldn't matter, but what happens if you change the order of the options?

     

    <select class="lia-form-boardDistributionFrequency-input" name="boardDistributionFrequency" id="boardDistributionFrequency" data-key="board.sub_email_delivery_freq">
    <option title="Sofort" value="immediate">Sofort</option>
    <option title="Nie" value="never">Nie</option>
    <option title="In einer Tagesübersicht" value="daily" selected="">In einer Tagesübersicht</option>
    <option title="In einer Wochenübersicht" value="weekly">In einer Wochenübersicht</option>
    </select>

     

    Again, it shouldn't matter, but what happens if you keep the option for 'never' in English?

     

    <select class="lia-form-boardDistributionFrequency-input" name="boardDistributionFrequency" id="boardDistributionFrequency" data-key="board.sub_email_delivery_freq">
    <option title="Never" value="never">Never</option>
    <option title="Sofort" value="immediate">Sofort</option>
    <option title="In einer Tagesübersicht" value="daily" selected="">In einer Tagesübersicht</option>
    <option title="In einer Wochenübersicht" value="weekly">In einer Wochenübersicht</option>
    </select>

     

    Lastly, what happen if you set the value to Immediate, manually. then try to set it up to Nie? You might receive an error 503 as the value is already set to Nie ...

     

  • tripp-bishop's avatar
    tripp-bishop
    Mentor
    10 years ago
    it sounds to me like the values of that profile field are constrained and that "never" is probably not a recognized value. Sometimes, REST calls will display a list of legal entries. Can you make a direct call and see if you can get back a useful error message rather than a useless 503?
  • micha80's avatar
    micha80
    Expert
    10 years ago

    OlivierS 

    tripp-bishop 

     

    Thanks for your replies!

     

    When I paste the following URL in the browser then I get an error 100: /users/self/profiles/name/board.sub_email_delivery_freq/set?value=never

     

    The error message is that the value must be one of the following values: immediate, daily, weekly

     

    But what if I want to set it to never which is an option on the original forms?

     

    Regards,

    Michael

  • tripp-bishop's avatar
    tripp-bishop
    Mentor
    10 years ago
    Have you tried not specifying any value? Definitely sounds like "never" is not a legal value.
  • tripp-bishop's avatar
    tripp-bishop
    Mentor
    10 years ago
    Turns out a cohort of mine is having this same issue. Will post back when we sort it out.
  • tripp-bishop's avatar
    tripp-bishop
    Mentor
    10 years ago
    I opened a support ticket and they believe it's a bug in the API. Will post more when I know it.
  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    micha80 tripp-bishop 

     

    I will make this public as there might be more people hitting this issue.

    The UI control you see is actually a combination of two different settings. The following are the "never" (false) versus not never (true) settings:

     

    profile.board.delivery_enable
    profile.label.delivery_enable
    profile.tag.delivery_enable
    profile.message.delivery_enable
    profile.search.delivery_enable
    profile.topic.delivery_enable
    profile.tkb.delivery_enable
    profile.mentions.delivery_enable
    profile.solutions.delivery_enable
    profile.kudo.delivery_enable
    profile.badge.delivery_enable
    profile.moderation_action.delivery_enable
    profile.helpfulness.delivery_enable

     And the following are the settings that have a string value: "immediate", "weekly", "daily".

     

    profile.board.sub_email_delivery_freq
    profile.label.sub_email_delivery_freq
    profile.tag.sub_email_delivery_freq
    profile.message.sub_email_delivery_freq
    profile.search.sub_email_delivery_freq
    profile.topic.sub_email_delivery_freq
    profile.mentions.sub_email_delivery_freq
    profile.solutions.sub_email_delivery_freq
    profile.tkb.sub_email_delivery_freq
    profile.kudo.sub_email_delivery_freq
    profile.badge.email_delivery_freq
    profile.moderation_action.sub_email_delivery_freq
    profile.helpfulness.sub_email_delivery_freq

     There are also these settings to enable/disable in-app realtime notifications:

     

    profile.board.in_app_delivery_enable
    profile.label.in_app_delivery_enable
    profile.tag.in_app_delivery_enable
    profile.message.in_app_delivery_enable
    profile.search.in_app_delivery_enable
    profile.topic.in_app_delivery_enable
    profile.tkb.in_app_delivery_enable

    Please note that all of these settings are actually wired up to the UI or the subscription backend ; so please don't assume a feature exists just because it is listed here.

     

    Edit:

     

    This setting doesn't do anything:

     

    profile.solutions.delivery_enable

    Instead, for solutions, use this setting:

     

    config.notify_solutions

     

     

     

  • sullysnack's avatar
    sullysnack
    Khoros Alumni (Retired)
    10 years ago

    I noticed another one with a mismatch... This setting doesn't do anything:

     

    profile.mentions.delivery_enable

    Instead, for mentions set this...

     

    mentions.notify_user_mentions

     to true when profile.mentions.sub_email_delivery_freq is immediate, daily or weekly... and set it to false for never.