Forum Discussion

vedagarw's avatar
8 years ago

Update User Profile Setting & Preferences In Custom Plugin

Hi,

We have a requirement to update the user profile data, preference etc from the custom plugin component. Is is possible to achieve this ? Also what is the best practice to get this done; should I user Rest API vs LIQL.

7 Replies

  • Hi vedagarw,

     

    I think APIv1 is a good point to start. You can use the profiles resource to set values, e.g.:

     

    <#assign response = restadmin("/users/id/${user_id?c}/profiles/name/<PROFILE_NAME>/set?value=<YOUR_VALUE>") />

    You can determine the profile name values using APIv1, too.

     

    Best regards,

    Christian

     

  • vedagarw's avatar
    vedagarw
    Guide
    8 years ago

    Using this I can update only couple of fields. I need to update all the settings and preferences for the user. Is there an API which would more wider set of fields to play with.

  • donpacote's avatar
    donpacote
    Helper
    8 years ago

    when i use this all time have a  permisions errors.   Add i use SSO auth.

     

    /restapi/vc/users/id/21405/profiles/name/aaaaaaa/set?restapi.response_format=json&restapi.session_key=ohL0ZHOrTRRrnbJ2HbJtR1R9kPOjybIqYsrhYQTjLy0.&value=aaaaaaa

     

    doestn work

     

     

  • cike's avatar
    cike
    Champion
    8 years ago

    donpacote - If you're making this request through your browser window, the call fails because there are some API restrictions on such calls. You have to use the restadmin keyword to make such calls.

     

    Best regards,

    Christian

  • donpacote's avatar
    donpacote
    Helper
    8 years ago

    ok thanks for your fast response. 

     

    Iam using eclipse to consume lithium services.  Can i use restadmin inside?

     

    my request makes :  /users/id/21405/profiles/name/aaaaaaa/set"; + new value + session_key. 

    Could you give some clue.

  • TariqHussain's avatar
    TariqHussain
    Boss
    8 years ago

    donpacote - 

    You can not use restadmin over HTTP calls .   

    if you have access to the studio. You can create an endpoint for this . Inside the endpoint, you can use restadmin call , this will bypass the permission issue. 

     

    You can refer these links for endpoints 

    https://community.lithium.com/t5/Components-endpoints-and-the/About-endpoints/ta-p/108971

    https://community.lithium.com/t5/Developers-Knowledge-Base/Working-with-Endpoints/ta-p/60240

     

    For restadmin

    https://community.lithium.com/t5/Developers-Discussion/What-is-restadmin/m-p/195062

     

    Tariq
    Give kudos if you find my posts helpful or mark solution if it answers your query

     

  • LuisDev's avatar
    LuisDev
    Contributor
    8 years ago

    i find the solution.

     

    My problem was in there :

     

    /users/id/21405/profiles/name/aaaaaaa/set";

     

    i mistake while i read documentacion.

     

    This aaaaaa should be an attribute from profile