Home
Create comments
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. Include the ID of the blog posting that you are commenting on in the comment Atom entry.
You 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.
See Authenticating requests for information about how to authenticate the request.
Atom API request details
Method Resource URI Input representation POST 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. comment POST Comments /services/atom/{handle}/comments {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.
This resource was introduced in the 1.x version of the Blogs API. It is provided here for backwards compatibility.
comment
Input
Provide a comment Atom entry document.The content type of the Atom entry document must be application/atom+xml.
If you are using the /services/atom/{handle}/comments resource to create a comment, provide the entry ID specified in the <thr:in-reply-to> element to indicate which entry the comment is for.
Output
An Atom entry document containing the new blog comment. Returned HTTP Headers
- HTTP/1.1 201 Created
- Indicates that the comment was successfully created. If an error occurs, this header will contain one of the error codes below.
- Location: url
- Link to the edit_url value of the blog entry comment that the author can use to subsequently retrieve or delete the blog entry.
Error codes
- HTTP/1.1 400 Bad Request
- HTTP/1.1 401 Unauthorized
Example
InputPOST /blogs/jjones/api/entrycomments/8af22760-ee1d-4e38-a588-6d0a0eec28d2 HTTP/1.1 Authorization: Basic ... Host: blogs.enterprise.acme.com:9444 Content-type: application/atom+xml <?xml version='1.0' encoding='UTF-8'?> <entry xmlns='http://www.w3.org/2005/Atom'> <id>ignored</id> <title type='text'>ignored</title> <content type='html'> <p>This time text</p> </content> </entry>Response
HTTP/1.1 201 Created Content-Type: application/atom+xml; type=entry Location: https://blogs.enterprise.acme.com:9444/blogs/jjones/api/comments/ 3499bd52-176d-4325-82c8-b89d202fcfeb <?xml version='1.0'?> <entry xmlns='http://www.w3.org/2005/Atom'> <id>urn:lsid:ibm.com:blogs:comment-3499bd52-176d-4325-82c8-b89d202fcfeb</id> <link href='https://blogs.enterprise.acme.com:9444/blogs/jjones/entry/ joe_api_created_blog_entry#comments-1211546063218' rel='alternate' type='text/html'/> <title type='text'>Re: Joe - API Created Blog Entry</title> <updated>2008-05-23T12:34:23.218Z</updated> <app:edited xmlns:app='http://www.w3.org/2007/app'>2008-05-23T12:34:23.218Z</app:edited> <published>2008-05-23T12:34:23.218Z</published> <author> <name>Bill User500</name> <email>juser500@acme.com</email> <snx:userid>937965j0-4f0c-1028-5a06-db07163b51b2</snx:userid> </author> <content type='html'> <p>This time text</p> </content> <thr:in-reply-to type='text/html' href='https://blogs.enterprise.acme.com:9444/blogs/jjones/entry/ joe_api_created_blog_entry' ref='urn:lsid:ibm.com:blogs:entry-8af22760-ee1d-4e38-a588-6d0a0eec28d2' xmlns:thr='http://purl.org/syndication/thread/1.0'/> <snx:rank scheme='http://www.ibm.com/xmlns/prod/sn/recommendations' xmlns:snx='http://www.ibm.com/xmlns/prod/sn'>0</snx:rank> </entry>
Related reference
Navigating Blogs subscription API resources
Navigating Blogs publishing API resources