Getting/Displaying User's Avatar via API

rated by 0 users
Answered (Verified) This post has 1 verified answer | 8 Replies | 3 Followers

Not Ranked
36 Posts
Points 430
mattb posted on Fri, May 16 2008 10:14 PM

This code:

public static string GetUserAvatar(string UserName)
{
MembershipService
service = new MembershipService("MySiteURL", "Me", "MyKey");
return service.GetUser(UserName).AvatarUrl;
}

Run with my name returns this:  http://community.mysite.com/api/membership.ashx/users/2100/avatar

How do I use that to get the path to the file so I can display in my image tag?

 

 

http://community.metalreview.com/forums

  • | Post Points: 20

Answered (Verified) Verified Answer

Top 10 Contributor
5,237 Posts
Points 48,205
CS Developers

There is currently an issue with the avatar handling that will be fixed in SP1.  The avatar support was added to the REST API before the avatars were moved into the new CFS storage framework, and the REST API wasn't updated to the new method.

If you go to the URL returned by AvatarUrl, it will return a 301 redirect to the actual avatar URL (though the URL that it returns is where the issue is).  In the SP1 client API, we will have a method on the MembershipService for getting the attachments that you'd be able to use.

  • | Post Points: 35

All Replies

Top 10 Contributor
5,237 Posts
Points 48,205
CS Developers

There is currently an issue with the avatar handling that will be fixed in SP1.  The avatar support was added to the REST API before the avatars were moved into the new CFS storage framework, and the REST API wasn't updated to the new method.

If you go to the URL returned by AvatarUrl, it will return a 301 redirect to the actual avatar URL (though the URL that it returns is where the issue is).  In the SP1 client API, we will have a method on the MembershipService for getting the attachments that you'd be able to use.

  • | Post Points: 35
Not Ranked
36 Posts
Points 430
mattb replied on Mon, May 19 2008 12:24 PM

 Ahhh... ok, thanks.

http://community.metalreview.com/forums

  • | Post Points: 5
Not Ranked
36 Posts
Points 430
mattb replied on Wed, Jul 9 2008 3:43 PM

Ken Robertson:

There is currently an issue with the avatar handling that will be fixed in SP1.  The avatar support was added to the REST API before the avatars were moved into the new CFS storage framework, and the REST API wasn't updated to the new method.

If you go to the URL returned by AvatarUrl, it will return a 301 redirect to the actual avatar URL (though the URL that it returns is where the issue is).  In the SP1 client API, we will have a method on the MembershipService for getting the attachments that you'd be able to use.



Any status update on when SP1 of the client API is going to get released?

http://community.metalreview.com/forums

  • | Post Points: 20
Top 10 Contributor
3,152 Posts
Points 46,820
TelligentSupportTeam

Isn't it the CommunityServer.WebServices.dll file included in the /bin/ of the CS2008 upgrade files?

  • | Post Points: 20
Not Ranked
36 Posts
Points 430
mattb replied on Wed, Jul 9 2008 4:13 PM

afscrome:

Isn't it the CommunityServer.WebServices.dll file included in the /bin/ of the CS2008 upgrade files?

Looks like the last one was updated in April?

http://community.metalreview.com/forums

  • | Post Points: 20
Top 10 Contributor
3,152 Posts
Points 46,820
TelligentSupportTeam

The one included in hte CS2008 SP1 download is a newer version than the April one from api.communityserver.org.  The SP1 dll is version 4.0.30610.12572

  • | Post Points: 20
Not Ranked
36 Posts
Points 430
mattb replied on Wed, Jul 9 2008 4:25 PM

The question is......    is this avatar issue fixed in this new version?  I will try my code.

http://community.metalreview.com/forums

  • | Post Points: 20
Not Ranked
7 Posts
Points 125
OnTheMike replied on Fri, Jul 11 2008 5:20 AM

Im using the latest dll's (from SP1) but it still returns the http://host.com/api/membership.ashx/users/2102/avatar. That should work fine, but it redirects the user to http://host.com~/cfs-file.ashx/__key/CommunityServer.Components.Avatars/00.00.00.21.02/avatar.jpg. Somehow this api-call doesn't use the ResolveUrl to get construct this Uri. Unfortunatly, if a user uploads a picture, you'll get the ~/cfs-file.ashx/__key/CommunityServer.Components.Avatars/00.00.00.21.02/avatar.jpg link as avatar, including the ~. If you remove the ~ from the userprofile it works fine. Looks like a bug to me...

  • | Post Points: 5
Page 1 of 1 (9 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com