Search code examples
javascriptjqueryajaxsbtibm-connections

Follow/Unfollow a resource in IBM Connections 5.5/6.0 using Ajax Request (jQuery)


I try to follow or unfollow a ressource in IBM Connections.

At the moment I try to follow a community in IBM Connections 6.0 using an AJAX Request but I always get a 400 Bad Request.

Can you help me ?

I use this documentation: https://www-10.lotus.com/ldd/lcwiki.nsf/xpAPIViewer.xsp?lookupName=IBM+Connections+6.0+API+Documentation#action=openDocument&res_title=Start_following_a_resource_ic60&content=apicontent

The AJAX Call:

var apiSourceIdentifier = 'communitities',
	apiTypeIdentifier = 'community',
	elementUuid = '41759ce1-3a88-4464-b912-8e54e7df453a', // That's a community uuid
	entryToPost = ['<entry>',
		'<category scheme="http://www.ibm.com/xmlns/prod/sn/source" term="' + apiSourceIdentifier + '"/>',
		'<category scheme="http://www.ibm.com/xmlns/prod/sn/resource-type" term="' + apiTypeIdentifier + '"/>',
		'<category scheme="http://www.ibm.com/xmlns/prod/sn/resource-id" term="' + elementUuid + '"/>',
		'</entry>'
	].join('');

$.ajax({
	method: "POST",
	url: '/communities/follow/atom/resources?source=communitities&type=community',
	cache: false,
	data: entryToPost,
	dataType: 'application/atom+xml',
	contentType: "application/atom+xml"
}).done(function() {
	alert('done!')
}).fail(function() {
	alert('failed');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


Solution

  • The part

    <category
    
    	term="resource-follow"
    
    	scheme="http://www.ibm.com/xmlns/prod/sn/type">
    
    	</category>

    is missing in your payload....