Create a community forum reply programmatically
To post a reply to a topic in a community forum, send an Atom entry document containing the forum reply to the forum replies resource.See Authenticating requests for information about how to authenticate the request.
To create a community forum reply, complete these steps:
- Retrieve the service document to discover the web address of the My Communities feed.
- Retrieve the My Communities feed, and then find the community to which you want to add the topic reply. Make a note of the web address in the href attribute of the rel="edit" <link> element.
- Send a GET request to the web address you noted in the previous step to retrieve the Atom entry document for the community. Look for the entry that represents the topic you want to reply to. Make a note of the web address of the rel="replies" <link> element.
- Send a POST request to the web address you noted in the previous step. Pass in to the request an Atom entry document that represents the reply you want to post.
Table 1. Atom API request details
Method Resource URI Input representation POST forum replies feed Value of the href attribute of the <link> element with the rel="replies" attribute value in the forum topics feed. forum reply
Input
Provide a forum reply Atom entry document.Note: The content type of the Atom entry document must be application/atom+xml.
Output
An Atom entry document containing the new forum reply.Returned HTTP headers
HTTP/1.1 201 Created
Indicates that the forum reply was successfully created. If an error occurs, this header contains one of the error codes.
Location: url
Link to edit_url of the forum reply. You can use the web address specified here to subsequently retrieve and update the forum reply.
- HTTP/1.1 400 Bad Request
- HTTP/1.1 401 Unauthorized
Example:
Request:
> POST /forums/atom/replies?topicUuid=37538e0f-6791-4fc9-9798-8f9c8206ae09 HTTP/ 1.1 > Authorization: xxx > Host: enterprise.example.com > Accept: */* > Content-Type: application/atom+xml > Content-Length: 821Entry document provided as input:
<?xml version="1.0" encoding="UTF-8"?> <entry xmlns:thr="http://purl.org/syndication/thread/1.0." xmlns:snx="http://www.ibm.com/xmlns/prod/sn" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2005/Atom"> <title type="text">Have you tried The Children's Place?</title> <category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="forum-reply"/> <thr:in-reply-to ref="urn:lsid:ibm.com:forum:37538e0f-6791-4fc9-9798-8f9c8206ae09" href="https://enterprise.example.com/forums/atom/topic?topicUuid= 37538e0f-6791-4fc9-9798-8f9c8206ae09" type="application/atom+xml" xmlns:thr="http://purl.org/syndication/thread/1.0."> </thr:in-reply-to> <category scheme="http://www.ibm.com/xmlns/prod/sn/flags" term="answer"/> <content type="html">Have you tried The Children's Place?</content> </entry>Response:
< HTTP/1.1 201 Created ...< <?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" xmlns:thr="http://purl.org/syndication/thread/1.0"><id>urn:lsid:ibm.com:for um:62812540-dce1-41cb-9dd3-504417252d56</id><title type="text">Have you tried Th e Children's Place?</title><published>2010-09-14T23:19:29.743Z</published><updat ed>2010-09-14T23:19:29.743Z</updated><author><email>jsmith@example.com</emai l><name>Amy Jones6</name><snx:userid>50730340-0101-102e-88e1-f78755f7e0ed</snx:u serid><snx:userState>active</snx:userState></author><link href="https://lc30linu x2.swg.usma.ibm.com/forums/atom/reply?replyUuid=62812540-dce1-41cb-9dd3-50441725 2d56" rel="self" type="application/atom+xml"></link><link href="https://lc30linu x2.swg.usma.ibm.com/forums/atom/reply?replyUuid=62812540-dce1-41cb-9dd3-50441725 2d56" rel="edit" type="application/atom+xml"></link><category term="forum-reply" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category><category term="answe r" scheme="http://www.ibm.com/xmlns/prod/sn/flags"></category><link href="https: //enterprise.example.com/forums/html/topic?id=37538e0f-6791-4fc9-9798-8f9c8 206ae09#62812540-dce1-41cb-9dd3-504417252d56" rel="alternate" type="text/html">< /link><link href="https://enterprise.example.com/forums/atom/replies?replyU uid=62812540-dce1-41cb-9dd3-504417252d56" rel="replies" type="application/atom+x ml" thr:count="0"></link><thr:in-reply-to ref="urn:lsid:ibm.com:forum:37538e0f-6 791-4fc9-9798-8f9c8206ae09" href="https://enterprise.example.com/forums/ato m/topics?forumUuid=37538e0f-6791-4fc9-9798-8f9c8206ae09" type="application/atom+ xml"></thr:in-reply-to><content type="html"> Have you tried The Children's Place? </content><snx:permissions>none, create_forum, view_forum, edit_forum, del_for um, create_post, edit_personal_post, edit_all_post, del_personal_post, del_all_p ost, pin_topic, subscribe, lock_node, create_topictag, del_all_topictag, del_per sonal_topictag, create_forumtag, del_all_forumtag, del_personal_forumtag, view_c ategory, edit_personal_question, edit_all_question</snx:permissions></entry>* Co nnection #0 to host enterprise.example.com left intact * Closing connection #0 * SSLv3, TLS alert, Client hello (1):
Parent topic
Work with community forum repliesRelated reference
Forum reply entry content
});