IBM Connections REST-API
Klompendans
Henning Schmidt
hedersoft GmbH
@schmhen
1#engageug
About.me
• Co-Founder and CEO of hedersoft
• CNX and Graph API Junkie
• System Architect
• Web Developer
• Speaker @ different events
twitter: schmhen – linkedin: de.linkedin.com/in/schmhen - blog: schmhen.de
About.hedersoft
Agenda
• Different APIs
• Example 1: Activity Stream
• Example 2: Embedded Experience
• Example 3: Forum Entry as Question
• Example 4: Wiki Entry
• Example 5: Blog Entry with Embedded Image
• Example 6: File Upload to Community
• Example 7: Email to Activity
• What to expect and get with Connections Pink
• API Real Life Usage
Different APIs
• REST APIs
• Service Provider Interfaces (SPIs)
• Event SPI – Hook into events to work with the event data
• Seedlist SPI – Integrate IBM Connections‘ into your search engine
• Service SPI – Learn about the different services provided by CNX
• User SPI – Obtain information about your IBM CNX Users
• The lc.spi.jar file contains the Server and User SPIs and is stored in
the EAR file in the root installation directory of the following
5#engageug
Example 1: Activity Stream
URL:
https://<host>/connect
ions/opensocial/<auth>
/rest/activitystreams/<
user ID>/<group ID>
Compoment Meaning
<auth> (optional) omit on form based authentication, otherwise use:
anonymos, basic, oauth.
<user ID> UserID to post to, @me = current User, alternatively:
CommunityUNID, ProfileID
IMPERSONATION!
<group ID> Group to post to
@self = my posts, @friends = friends posts, @all = all posts, ... .
Only @self supported at the moment, more in the infocenter!
Example 1: Activity Stream
{
"actor": {
"id": "@me"
},
"verb": "post",
"title": “Presenting the REST-API Klompendans",
"content": "This event is my <b>first entry</b>",
"object": {
"summary": "First Entry details",
"objectType": "note",
"id": "objectid",
"displayName": "First entry“
}
}
[entry.title]
[entry.content]
[entry.object.summary]
Henning Schmidt posted [entry.object.displayame]
[entry.content]
[entry.object.summary]
DEMO
8#engageug
Example 2: Embedded Experience
Example 2: Embedded Experience
{
"actor": {"id": "@me"},
"verb": "post",
"content": "This event is my <b>Embedded Experience!</b>",
"object": {
"summary": "Have a look at hedersoft:",
...
},
"openSocial": {
"embed": {
"gadget":
"https://apps.na.collabserv.com/connections/resources/web/com.ibm.social.ee.cloud/cloudee.xml",
"context": {
"url":"https://www.hedersoft.de",
"height": "400"
}
}
}}
DEMO
11#engageug
Example 3: Forum Entry as Question
URL
https://<host>/forums/atom/topics?forumUuid=xyz
Query Params
forumUuid – The Uuid of the forum to post to
atom+xml (as the rest of the APIs) 
Example 3: Forum Entry as Question
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">I have a question</title>
<content type="html">Do you think SS Rotterdam is an awesome
venue?</content>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type"
term="forum-topic"></category>
<category scheme="http://www.ibm.com/xmlns/prod/sn/flags"
term="question"/>
<category term="question"></category>
<category term=“rotterdam"></category>
<category term="2017"></category>
</entry>
DEMO
14#engageug
Example 4: Wiki Entry
URL
https://<host>/wikis/basic/api/wiki/<wiki-
label>/feed
CDATA HTML content
<content type="text/html"><![CDATA[<?xml version="1.0"
encoding="UTF-8"?><!DOCTYPE html [<!ENTITY amp
"&#38;#38;"><!ENTITY lt "&#60;#60;"><!ENTITY gt
"&#62;#62;"><!ENTITY nbsp "&#160;"><!ENTITY apos
"&#39;"><!ENTITY quot "&#34;">]> <div></div>]]></content>
Attention: Wiki’s do have a very narrow HTML interpretation,
my favorite source of problems
Example 4: Wiki Entry
Impersonation API
• Allows to act on behalf of someone else
• Special admin rights needed!
• OnPrem: Websphere config
(trustedExternalApplication)
• Cloud: Mail to IBM, request API activation
Header
X-LConn-RunAs: userid=2368723457
DEMO
17#engageug
Example 5: Blog Entry with Embedded Image
URL
https://<host>/blogs/<blog-id>/api/entries
• Up to 5.0 – Base 64 encoded Image
• Since 5.5 – Upload Image and Link
• Escape HTML content in payload
DEMO
19#engageug
Example 6: File Upload to Community
URL
https://<host>/files/basic/api/communitylibrary/<communi
ty-id>/feed
To add to folder first upload file and then move
https://<host>/files/basic/api/library/<folder-
id>/document/<file-id>/entry
Get nonce first
https://<host>/files/basic/api/nonce
Headers
Content-Type, Content-Length, Slug, X-Update-Nonce
DEMO
21#engageug
Example 7: Email to Activity
URL
https://<host>/activities/service/atom2/activity?acti
vityUuid=xyz
Query Parameter
activityUuid – Id of the activity to add item to
• Escape Content (<div> -> &lt;div&gt;)
• Do not forget namespaces!
DEMO
23#engageug
What to expect and get with Connections Pink
API Real Life Usage
• Source
• Notes Database (3GB)
• 34 categories, 2906 documents
• 25 categories migrated and 5 synchronized
• Destination
• 30 different communities
• Formatting of RichText, Definition of Tags
• Embedded Images
• -> IBM Connections Wiki and Files
POWERED BY
Lessons learned
• Different applications = Non-unique APIs
• Impersonation: X-LConn-RunAs
• Different payloads and pitfalls in different applications
• Standalone App or Community App makes no difference, except
for URL
• Embedded Images as Files (CNX 5.5+)
• Use Postman to test the APIs
• Connections Pink: Coexistence of APIs
THANK YOU!

IBM Connections REST API Klompendans

  • 1.
    IBM Connections REST-API Klompendans HenningSchmidt hedersoft GmbH @schmhen 1#engageug
  • 2.
    About.me • Co-Founder andCEO of hedersoft • CNX and Graph API Junkie • System Architect • Web Developer • Speaker @ different events twitter: schmhen – linkedin: de.linkedin.com/in/schmhen - blog: schmhen.de
  • 3.
  • 4.
    Agenda • Different APIs •Example 1: Activity Stream • Example 2: Embedded Experience • Example 3: Forum Entry as Question • Example 4: Wiki Entry • Example 5: Blog Entry with Embedded Image • Example 6: File Upload to Community • Example 7: Email to Activity • What to expect and get with Connections Pink • API Real Life Usage
  • 5.
    Different APIs • RESTAPIs • Service Provider Interfaces (SPIs) • Event SPI – Hook into events to work with the event data • Seedlist SPI – Integrate IBM Connections‘ into your search engine • Service SPI – Learn about the different services provided by CNX • User SPI – Obtain information about your IBM CNX Users • The lc.spi.jar file contains the Server and User SPIs and is stored in the EAR file in the root installation directory of the following 5#engageug
  • 6.
    Example 1: ActivityStream URL: https://<host>/connect ions/opensocial/<auth> /rest/activitystreams/< user ID>/<group ID> Compoment Meaning <auth> (optional) omit on form based authentication, otherwise use: anonymos, basic, oauth. <user ID> UserID to post to, @me = current User, alternatively: CommunityUNID, ProfileID IMPERSONATION! <group ID> Group to post to @self = my posts, @friends = friends posts, @all = all posts, ... . Only @self supported at the moment, more in the infocenter!
  • 7.
    Example 1: ActivityStream { "actor": { "id": "@me" }, "verb": "post", "title": “Presenting the REST-API Klompendans", "content": "This event is my <b>first entry</b>", "object": { "summary": "First Entry details", "objectType": "note", "id": "objectid", "displayName": "First entry“ } } [entry.title] [entry.content] [entry.object.summary] Henning Schmidt posted [entry.object.displayame] [entry.content] [entry.object.summary]
  • 8.
  • 9.
  • 10.
    Example 2: EmbeddedExperience { "actor": {"id": "@me"}, "verb": "post", "content": "This event is my <b>Embedded Experience!</b>", "object": { "summary": "Have a look at hedersoft:", ... }, "openSocial": { "embed": { "gadget": "https://apps.na.collabserv.com/connections/resources/web/com.ibm.social.ee.cloud/cloudee.xml", "context": { "url":"https://www.hedersoft.de", "height": "400" } } }}
  • 11.
  • 12.
    Example 3: ForumEntry as Question URL https://<host>/forums/atom/topics?forumUuid=xyz Query Params forumUuid – The Uuid of the forum to post to atom+xml (as the rest of the APIs) 
  • 13.
    Example 3: ForumEntry as Question <?xml version="1.0" encoding="UTF-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <title type="text">I have a question</title> <content type="html">Do you think SS Rotterdam is an awesome venue?</content> <category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="forum-topic"></category> <category scheme="http://www.ibm.com/xmlns/prod/sn/flags" term="question"/> <category term="question"></category> <category term=“rotterdam"></category> <category term="2017"></category> </entry>
  • 14.
  • 15.
    Example 4: WikiEntry URL https://<host>/wikis/basic/api/wiki/<wiki- label>/feed CDATA HTML content <content type="text/html"><![CDATA[<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html [<!ENTITY amp "&#38;#38;"><!ENTITY lt "&#60;#60;"><!ENTITY gt "&#62;#62;"><!ENTITY nbsp "&#160;"><!ENTITY apos "&#39;"><!ENTITY quot "&#34;">]> <div></div>]]></content> Attention: Wiki’s do have a very narrow HTML interpretation, my favorite source of problems
  • 16.
    Example 4: WikiEntry Impersonation API • Allows to act on behalf of someone else • Special admin rights needed! • OnPrem: Websphere config (trustedExternalApplication) • Cloud: Mail to IBM, request API activation Header X-LConn-RunAs: userid=2368723457
  • 17.
  • 18.
    Example 5: BlogEntry with Embedded Image URL https://<host>/blogs/<blog-id>/api/entries • Up to 5.0 – Base 64 encoded Image • Since 5.5 – Upload Image and Link • Escape HTML content in payload
  • 19.
  • 20.
    Example 6: FileUpload to Community URL https://<host>/files/basic/api/communitylibrary/<communi ty-id>/feed To add to folder first upload file and then move https://<host>/files/basic/api/library/<folder- id>/document/<file-id>/entry Get nonce first https://<host>/files/basic/api/nonce Headers Content-Type, Content-Length, Slug, X-Update-Nonce
  • 21.
  • 22.
    Example 7: Emailto Activity URL https://<host>/activities/service/atom2/activity?acti vityUuid=xyz Query Parameter activityUuid – Id of the activity to add item to • Escape Content (<div> -> &lt;div&gt;) • Do not forget namespaces!
  • 23.
  • 24.
    What to expectand get with Connections Pink
  • 25.
    API Real LifeUsage • Source • Notes Database (3GB) • 34 categories, 2906 documents • 25 categories migrated and 5 synchronized • Destination • 30 different communities • Formatting of RichText, Definition of Tags • Embedded Images • -> IBM Connections Wiki and Files POWERED BY
  • 26.
    Lessons learned • Differentapplications = Non-unique APIs • Impersonation: X-LConn-RunAs • Different payloads and pitfalls in different applications • Standalone App or Community App makes no difference, except for URL • Embedded Images as Files (CNX 5.5+) • Use Postman to test the APIs • Connections Pink: Coexistence of APIs
  • 27.