Forum Discussion

cblown's avatar
cblown
Boss
12 years ago

Lithium Custom Settings - Unable to SET as user

We have a custom setting called user.data (Lithium have setup for us) that is scoped to wcu (world, community, user).

 

We are trying to SET this custom setting using AJAX - the user account has GRANT for Make REST API calls with modify access

 

Code

 

<@liaAddScript>
;(function($) {
   $.post("/restapi/vc/users/self/settings/name/user.data/set", {value: "my user data"}).done(function(data) {
       alert(data);
   }).fail(function() {
       alert("error");
   }).always(function() {
       alert("finished");
   });
})(LITHIUM.jQuery);
</@liaAddScript>

 

Response

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<response status="error">
<error code="303">
<message>
     User[uid=2369] cannot set field &apos;user.data&apos; on object User[uid=2369]
</message>
</error>
</response>

 

 

 

 

 

  • I'm not sure, but I would try to use a custom user profile instead of settings.
    I did a quick test and the code works fine in that case, the call would be something like:

     

    $.post("/restapi/vc/users/self/profiles/name/user.data/set", {value: "my user data"})

    Check with Lithium support if they can change the current definition to a "profile" one...

  • ChiaraS's avatar
    ChiaraS
    Lithium Alumni (Retired)

    looking at the way the setting was defined, I think you should use "hinterlands.user.data" instead of just "user.data"

    • cblown's avatar
      cblown
      Boss

      Sorry, the original source has hinterlands.user.data - we removed the hinterlands from the source (so as not to include this in the post)

       

      Anyway even with that set we still get the same error response. 

       

      Are users able to set their own custom settings, or is this an admin only function?

       

      • ChiaraS's avatar
        ChiaraS
        Lithium Alumni (Retired)

        I'm not sure, but I would try to use a custom user profile instead of settings.
        I did a quick test and the code works fine in that case, the call would be something like:

         

        $.post("/restapi/vc/users/self/profiles/name/user.data/set", {value: "my user data"})

        Check with Lithium support if they can change the current definition to a "profile" one...