Creating comments
Added by IBM contributorIBM | Edited by IBM contributorPaul Bastide on December 21, 2015
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

To add a comment to a blog posting, send a comment Atom entry document to the web address specified in the href attribute of the Comments <collection> element of the blog as specified in the service document or send the comment Atom entry document directly to the comments feed.
The users can use the API to create and retrieve comments. However, after comments are created, they cannot be modified. Only the blog owner can delete comments.

To create a blog comment, complete the following steps:

1. Retrieve the Blogs service document. See Retrieving the Blogs service document.
2. In the service document, locate the workspace for the blog, locate the Comment Entries Atom collection within the workspace, and then copy the web address in the href attribute of the Comments collection.
3. Determine the ID of the entry that you want to add the comment as a response to by getting a feed of the entries in the blog. You can do so by sending a GET request to the web address in the href attribute of the Weblog Entries collection. From the returned feed, find the blog of interest and the entry to which you want to add a comment. Copy the value of the <id> element for that entry.
4. Send a POST request to the web address that you noted in the previous step. Pass a comment Atom entry document as input on the request. In the Atom document, define the entry that you want to add the comment to and the content of the comment itself.

Note: If you are using the URL from the publishing API service document or the /services/atom/{handle} /comments resource to create a comment, provide the entry ID specified in the element to indicate which entry the comment is for.
Note: Include the ID of the blog posting that you are commenting on in the comment Atom entry.

Note: The content type of the Atom entry document must be application/atom+xml.

Method URI Description
POST /blogs/{handle}/api/comments Value of the href attribute of the <collection> element with a child <title> element having a value of Comments in each blog workspace in the service document.
Content Type: application/atom+xml
Sample Request:
<?xml version="1.0" encoding="UTF-8"?>






	<title type='text'>ignored</title>

	<thr:in-reply-to ref="" href="" type="text/html" xmlns:thr="">

	<content type='html'>

	I love to comment on topics.


Name Type Optional Description
string No {handle} represents the blog handle. A handle is specified when a blog is first created and is used in the construction of web addresses used to query the entries in a blog.
The handle can be the Community Uuid.
Name Type Optional Description
string Yes The value should be in such format: userid=<user ext id>,username=<user name>,useremail=<user mail> .
This header enables impersonation and must works with Blogs admin user to authenticate request. If the user does not exists, an inactive user will be created with specified userid , username and usermail. If the user exists, username and useremail can be omitted.
string No The Nonce value, which should be retrieved from the nonce service in Files/Wikis and then used to create comments.
Content Type: application/atom+xml
Name Type Optional Description
string No Link to the edit_url value of the blog entry comment that the author can use to subsequently retrieve or delete the blog entry.
Code Description
Indicates that the comment was successfully created. If an error occurs, this header contains one of the error codes.
Bad Request.
> POST /blogs/myblog/api/comments HTTP/1.1

	> Authorization: Basic xxx

	> Host:

	> Accept: */*

	> Content-Type: application/atom+xml

	> Content-Length: 353

Comment Atom entry document provided as input to the request:

<?xml version='1.0' encoding='UTF-8'?>

	<entry xmlns='' xmlns:thr="">


	<title type='text'>ignored</title>

	<thr:in-reply-to ref=""/>

	<content type='html'>

	I love to comment on topics.



Response returned by the server
< HTTP/1.1 201 Created

	< Date: Tue, 03 Aug 2010 19:24:42 GMT

	< Server: IBM_HTTP_Server

	< X-LConn-Auth: false

	< X-UA-Compatible: IE=EmulateIE7

	< Expires: Thu, 1 Jan 1970 00:00:00 GMT

	< Cache-Control: no-store, no-cache, must-revalidate

	< Location:


	< Content-Location:


	< Last-Modified: Tue, 03 Aug 2010 19:24:44 GMT

	< Set-Cookie: ...

	< Set-Cookie: ...

	< Set-Cookie: JSESSIONID=...

	< Transfer-Encoding: chunked

	< Content-Type: application/atom+xml; type=entry

	< Content-Language: en-US


	<?xml version="1.0"?>

	<entry xmlns="">
























	<atom:title xmlns:atom="">



	<atom:category term="recommend" scheme="" xmlns:atom="">


	<app:categories fixed="yes"></app:categories>


	<snx:moderation status="approved" xmlns:snx=""></snx:moderation>

	<title type="text">Re: just below</title>


	<app:edited xmlns:app="">2010-08-03T19:24:44.351Z</app:edited>



	<name>Jim Smith</name>


	<snx:userid xmlns:snx="">4fda6cc0-0101-102e-88dd-f78755f7e0ed</snx:userid>

	<snx:userState xmlns:snx="">active</snx:userState>


	<content type="html"> I love tocomment on topics. </content>







	<snx:trackbacktitle xmlns:snx="">Jim Smith</snx:trackbacktitle>

	<snx:rank scheme="" xmlns:snx="">0</snx:rank>

	<app:control xmlns:app="">


	<snx:approved xmlns:snx="">yes</snx:approved>



	* Connection #0 to host left intact

	* Closing connection #0

	* SSLv3, TLS alert, Client hello (1):