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.

Input
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"?>

<entry 

 xmlns="http://www.w3.org/2005/Atom" 

 xmlns:app="http://www.w3.org/2007/app" 

 xmlns:snx="http://www.ibm.com/xmlns/prod/sn">

	<id>ignored</id>

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

	<thr:in-reply-to ref="urn:lsid:ibm.com:blogs:entry-874f563b-a167-4dca-be07-57bb36380c28" href="https://greenhousestage.lotus.com/blogs/050c03c9-e062-4804-a6fc-0462c880fcaf/entry/entry_to_blog_test" type="text/html" xmlns:thr="http://purl.org/syndication/thread/1.0">
</thr:in-reply-to>

	<content type='html'>

	I love to comment on topics.

	</content>

	</entry>
Name Type Optional Description
handle
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
X-LConn-RunAs
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.
eg:userid=BFB5FDCB-B0E2-408A-A351-09103D8D5527,username=xxxxxx,useremail=xxxx@cn.ibm.com
X-Update-Nonce
string No The Nonce value, which should be retrieved from the nonce service in Files/Wikis and then used to create comments.
Output
Content Type: application/atom+xml
Name Type Optional Description
Location
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
201
Indicates that the comment was successfully created. If an error occurs, this header contains one of the error codes.
400
Bad Request.
401
Unauthorized.
Examples
> POST /blogs/myblog/api/comments HTTP/1.1

	> Authorization: Basic xxx

	> Host: enterprise.example.com

	> 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='http://www.w3.org/2005/Atom' xmlns:thr="http://purl.org/syndication/thread/1.0">

	<id>ignored</id>

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

	<thr:in-reply-to ref="urn:lsid:ibm.com:blogs:entry-49d22e3e-4f0f-4499-b979-d64dc23ad21d"/>

	<content type='html'>

	I love to comment on topics.

	</content>

	</entry>


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: https://enterprise.example.com:443/blogs/myblog/api/comments/

	c2d87716-e965-4077-9a0b-f679f6d83d3a

	< Content-Location: https://enterprise.example.com:443/blogs/myblog/api/c

	omments/c2d87716-e965-4077-9a0b-f679f6d83d3a

	< 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="http://www.w3.org/2005/Atom">

	<id>urn:lsid:ibm.com:blogs:comment-c2d87716-e965-4077-9a0b-f679f6d83d3a</id>

	<link

	href="https://enterprise.example.com:443/blogs/myblog/api/c2d87716-e965-4077-9a0b-f679f6d83d3a"

	rel="edit"

	type="application/atom+xml">

	</link>

	<link

	href="https://enterprise.example.com/blogs/myblog/entry/just_below#comments-1280863484351"

	rel="alternate"

	type="text/html">

	</link>

	<link

	href="http://enterprise.example.com/blogs/issuecategories"

	rel="http://www.ibm.com/xmlns/prod/sn/issues">

	</link>

	<link

	href="http://enterprise.example.com/blogs/home/api/reports/comments/c2d87716-e965-4077-9a0b-f679f6d83d3a"

	rel="http://www.ibm.com/xmlns/prod/sn/reports"

	type="application/atom+xml">

	</link>

	<app:collection

	href="https://enterprise.example.com:443/blogs/myblog/api/recommend/comments/c2d87716-e965-4077-9a0b-f679f6d83d3a"

	xmlns:app="http://www.w3.org/2007/app">

	<atom:title xmlns:atom="http://www.w3.org/2005/Atom">

	Recommendations

	</atom:title>

	<atom:category term="recommend" scheme="http://www.ibm.com/xmlns/prod/sn/collection" xmlns:atom="http://www.w3.org/2005/Atom">

	</atom:category>

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

	</app:collection>

	<snx:moderation status="approved" xmlns:snx="http://www.ibm.com/xmlns/prod/sn"></snx:moderation>

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

	<updated>2010-08-03T19:24:44.351Z</updated>

	<app:edited xmlns:app="http://www.w3.org/2007/app">2010-08-03T19:24:44.351Z</app:edited>

	<published>2010-08-03T19:24:44.351Z</published>

	<author>

	<name>Jim Smith</name>

	<email>jsmith@example.com</email>

	<snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">4fda6cc0-0101-102e-88dd-f78755f7e0ed</snx:userid>

	<snx:userState xmlns:snx="http://www.ibm.com/xmlns/prod/sn">active</snx:userState>

	</author>

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

	<thr:in-reply-to

	ref="urn:lsid:ibm.com:blogs:entry-49d22e3e-4f0f-4499-b979-d64dc23ad21d"

	href="https://enterprise.example.com/blogs/myblog/entry/just_below"

	type="text/html"

	xmlns:thr="http://purl.org/syndication/thread/1.0">

	</thr:in-reply-to>

	<snx:trackbacktitle xmlns:snx="http://www.ibm.com/xmlns/prod/sn">Jim Smith</snx:trackbacktitle>

	<snx:rank scheme="http://www.ibm.com/xmlns/prod/sn/recommendations" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">0</snx:rank>

	<app:control xmlns:app="http://www.w3.org/2007/app">

	<app:draft>no</app:draft>

	<snx:approved xmlns:snx="http://www.ibm.com/xmlns/prod/sn">yes</snx:approved>

	</app:control>

	</entry>

	* Connection #0 to host enterprise.example.com left intact

	* Closing connection #0

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