cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Fetch user's avatar

srude
1-Visitor

Fetch user's avatar

I am creating Service for obtaining user's avatar:

var currentUser = Resources["CurrentSessionInfo"].GetCurrentUser();

var result = Users[currentUser].getAvatarURL();

But I am getting 500th server error code. Could you please point me out my mistake and help me fix my code.

I asked my question also on https://stackoverflow.com/questions/36771705/thingworx-fetch-users-avatar

Thanks in advance! I appreciate your help!

ACCEPTED SOLUTION

Accepted Solutions
Aanjan
12-Amethyst
(To:srude)

Serg, sorry, I had misread your question. This does work for me -

var currentUser = Resources["CurrentSessionInfo"].GetCurrentUser();

var result = Users[currentUser].GetAvatarURL();

currentUser stores Administrator, and I've set output of the service to STRING and I get the following as my result -

/Thingworx/Users/Administrator/Avatar

View solution in original post

5 REPLIES 5
Aanjan
12-Amethyst
(To:srude)

Serg, if you're fetching the current user's avatar, you can use

var result = me.GetAvatarURL();

srude
1-Visitor
(To:Aanjan)

Aanjan, first of all thank you for your attention.

I want avatar be dynamically return depends on who logged in.

So I decided create HelperThing and implemented service above in this  HelperThing, if  I call me.GetAvatarURL(); - it will return me Avatar of HelperThing.

Aanjan
12-Amethyst
(To:srude)

Serg, sorry, I had misread your question. This does work for me -

var currentUser = Resources["CurrentSessionInfo"].GetCurrentUser();

var result = Users[currentUser].GetAvatarURL();

currentUser stores Administrator, and I've set output of the service to STRING and I get the following as my result -

/Thingworx/Users/Administrator/Avatar

srude
1-Visitor
(To:Aanjan)

Aanjan, sounds good. Seems if narrow down the problem. I would like to return IMAGELINK. Could you, please, show me the casting.

Aanjan
12-Amethyst
(To:srude)

Serg, you can use the same code from above, and set the service output to IMAGELINK instead of STRING. You would get the image/ icon of that user.

Announcements


Top Tags