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

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    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
      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

        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