Update user avatar via PublicApi


I am adding users to the system via calls to PublicApi.Users.Create, however I cannot see where I can update the user's avatar. I can see an equivalent call is available via the REST APi, how do I do it within the PublicAPi?


  •  - I can not find this in the PublicApi either, however I did find two alternatives:

    1.  The OOTB modal utilizes the following to update a user's uploaded avatar:

    using (Stream inputStream = this.UploadedFile.InputStream)
            user.AvatarUrl = Telligent.Evolution.Avatars.UpdateAvatar(user.UserID, inputStream);

    2.  Another possibility would be to use the same IUserService (in the rest namespace) that the REST endpoints use

     var avatarService = Services.Get<Telligent.Evolution.Rest.Resources.Users.UserService>();
     avatarService.UpdateUserAvatar(// params);

    However I am not sure about the ramifications of using this outside of a REST call, and looking closer, this call uses the same underlying code as in option #1.  

    Have you thought about just calling the REST endpoint to update the avatar from within your C# class?  It may be more of a hassle, but would be supported.

  • In reply to Luke D:

    how will i save the AvatarUrl after this code

    user.AvatarUrl = Telligent.Evolution.Avatars.UpdateAvatar(user.UserID, inputStream);

  • In reply to nibble:

    So first, the call  Telligent.Evolution.Avatars.UpdateAvatar(user.UserID, inputStream); sets the avatar, you then need to re-retrieve the user.

    But I must highly advise against this.  You can use the rest endpoint in your code through a simple Web Request and it will be supported and upgrade safe.

    In-Process support for avatar updating will not be available until the next major release.