Invoking the IBM Connections REST APIs from XPages

As part of my blog series I describe below some tips and tricks for how to use the Connections REST APIs from XPages.

I strongly suggest to use the XPages Social Enabler infrastructure which is included in the Extension Library project on OpenNTF. I documented most of the functionality in chapter 13 of the new XPages book.

There is also some documentation on OpenNTF and David Leedy created a cheatsheet describing how to get started.

You should use the latest extension library from OpenNTF (you need at least the June 2012 release) since this version comes with LTPA based single sign on.

The Connections wiki contains documentation about the REST APIs. The getting started gives some samples for typical API calls, e.g. to get a list of the communities of the current user:

One thing I had to learn was that the documentation mostly doesn’t define the URLs of the REST APIs. Instead it only says that the URLs should be read via another URL request for the applications’ service documents, e.g. to find out the URL to get the user’s status.

In some cases absolute URLs are defined in the wiki. For example the documentation to find specific user profiles defines the URL “/atom/”. It took me some time though to figure out that I actually had to use “/profiles/atom/” to get the profile feed.

Here is a simple sample for how to read the name of a user given the user’s id. In the NSF’s file I define to use the connectionsLtpa bean when the name ‘connections’ is used.


In faces-config.xml I define the managed bean:

In the Java code you can then use ConnectionsService and the method get, post, put and delete to invoke the REST APIs. There is a convenience API sbt.XmlNavigator to easily parse the Atom/XML output.

In my Lotusphere session I used another sample which posted information to Connections: