With the release of CS2008, we have released the REST webservice code for the first time... This webservice has a client API which is used by the server, and actually is in the bin folder of your CS site... CommunityServer.WebServices.dll. Referencing this file in a project will allow you to do things like.
Service rest = new Service("http://localhost/cs");List<BlogGroup> blogGroups = rest.Blogs.GetBlogGroups();
This is all being documented here at http://api.communityserver.org
There are some places however, where the client api might not yet have an implementation for accessing endpoints on the server. For those cases I wrapped and exposed the communications calls in the dll. Allowing for calls like.
ManualRequest rest = new ManualRequest("http://localhost/cs");BlogGroupListSerialized blogGroupListSerialized = rest.Get(rest.Urls.BlogGroupsUrl()).GetResponseObject<BlogGroupListSerialized>();
The methods return strings, which are XML.. So you can use the GetResponseObject to get the related Type, or just use XPath and open the doc as native XML.
A place where we are missing some client api methods for example are things like post extedned attributes or ratings...
RatingListSerialized ratingListSerialized = rest.Get(rest.Urls.BlogPostRatingUrl(blogId, blogPostId));
or
//rate a post with 4 starsint responseRating = rest.Put(rest.Urls.BlogPostRatingUrl(blogId, blogPostId, username), "<int>4</int>");
Extended attributes are availabe for "Section" objects, "Post" objects and "User" objects (except for posts in a group / hub)
endpoint urls would be like
/api/blogs.ashx/blogs/{blogid}/attributes returns an ExtendedAttributeListSerialized object which is a list of ExtendedAttributeSerialized objects (Supports GET HEAD and POST)
ExtendedAttributeListSerialized attributeListSerialized = rest.Get("http://localhost/cs/api/blogs.ashx/blogs/10/attributes");
/api/blogs.ashx/blogs/{blogid}/attributes/{attribute name} which returns a <string> (Supports GET HEAD PUT and DELETE)
string attribute = rest.Get("http://localhost/cs/api/blogs.ashx/blogs/10/attributes/abouttitle");
Only site admins can access extended attribute urls. You PUT and POST XML encoded strings... like <string>Hello World</string>
A compiled DLL (DanBartels.CS.REST.Dll) is included as well as the source and some basic unit tests... Assuming you have your CS install available with the sample data at http://localhost/cs
Dan