Skip to end of metadata
Go to start of metadata

About

Atom APIs provided with IBM® Connections 4 allows to start following a resource included a community, all you need to do is to send a follow Atom entry document on the request to identify what community you want to start following. Here's one easy way to do it with an asynchronous HTTP (Ajax) request using jQuery.

IBM Connections 4 documentation link: Start following a resource

Atom API Request Details

Headers

application/atom+xml; charset=UTF-8

Type

POST

URL

{host}/communities/follow/atom/resources?source=communities&type=community

Pass a follow Atom entry document on the request to identify what community you want to start following.

Example

http://www.mysite.com/communities/follow/atom/resources?source=communities&type=community

Response

Status Code: 200 OK

Example Atom Entry

<?xml version="1.0" encoding="UTF-8"?>
<entry>
    <id>urn:lsid:ibm.com:follow:resource-f8be0-4be5-4cba-8a2e-743f97</id>
    <category term="resource-follow" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
    <category term="communities" scheme="http://www.ibm.com/xmlns/prod/sn/source"></category>
    <category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/resource-type"></category>
    <category term="f8be0-4be5-4cba-8a2e-743f97" scheme="http://www.ibm.com/xmlns/prod/sn/resource-id">
    </category>
</entry>

Note

In lines 3 and 7 add the Id of the Community to follow

Example using jQuery

var strData = '<?xml version="1.0" encoding="UTF-8"?>';
strData += '<entry><id>urn:lsid:ibm.com:follow:resource-f8be0-4be5-4cba-8a2e-743f97</id>';
strData += '<category term="resource-follow" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>';
strData += '<category term="communities" scheme="http://www.ibm.com/xmlns/prod/sn/source"></category>';
strData += '<category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/resource-type"></category>';
strData += '<category term="f8be0-4be5-4cba-8a2e-743f97" scheme="http://www.ibm.com/xmlns/prod/sn/resource-id"></category></entry>';    

$.ajax({
    url : "http://www.mysite.com/communities/follow/atom/resources?source=communities&type=community ",
    type : "POST",
    contentType: "application/atom+xml; charset=UTF-8",
    async : true,
    data: strData,
    statusCode : {
        200 : function() {
            console.log('success');
        }
    },
    error: function(jqXHR, textStatus, errorThrown) {
        console.log(jqXHR + " - " + textStatus + ' - ' + errorThrown);
    }
});

Note:  console.log can throw errors in IE, they are there for illustrative purposes only and should be changed as required.

About the author

Enterprise Web Developer
Joaquin is an Enterprise Web Developer at Base22 with over seven years of experience designing and developing web solutions for enterprise clients. He is a well rounded web developer with skills building interfaces in IBM WebSphere Portal and WCM, IBM Connections, and many others. He is an Oracle Certified Java Developer and a Microsoft Certified Visual Studio Developer. He blogs at http://j-arellano.com