posts - 380, comments - 634, trackbacks - 117,
Dan Bartels online engineering logbook... Items that I find useful organized for my use, and indexed by google for yours. Here you can find information about Microsoft C# programming, SQL SERVER 2005, Telligent Systems CommunityServer, Dot Net Nuke, Windows Vista / Longhorn, and just about anything else that would compel me to type.

News

What I am Reading:


Professional Community Server

Past books can be viewed on:

Post Categories

Archives

Coding Techniques

Coding Tools

Community Sites

Deal Finders

Friends Businesses

Microsofties

Smartphones

Utilities

my blogmap
Color outside the lines with the CS API

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 stars
int 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");

or

/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

Published Wednesday, April 30, 2008 4:31 PM by DanB

Filed under , , ,

Attachment(s): DanBartels.CS.REST_5.0.30430.zip
::

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 
 
Powered by Community Server (Commercial Edition), by Telligent Systems
powered by god (with a little help from Telligent Systems - Community Server 2.1)