Community articleCreating a community forum reply programmatically
Added by IBM contributorIBM on April 3, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

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.
Tags: commapi



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:

1. Retrieve the service document to discover the web address of the My Communities feed.
2. 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.
3. 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.
4. 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.

Input

Provide a forum reply Atom entry document.

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

To create a reply with an attachment, use a multipart post in the request. See Creating a stand-alone forum topic programmatically for more details.

Output

An Atom entry document containing the new forum reply.

Example:

Entry 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> 


Input
Method URI Description
POST /forums/atom/replies Value of the href attribute of the <link> element with the rel="replies" attribute value in the forum topics feed.
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"
    xmlns:thr="http://purl.org/syndication/thread/1.0">
 
    
        <title type="text">Stage Test Community DT Topics and Replies</title>
        
    <title type="text">Re: test topic dt</title>
    <category term="NotRecommendedByCurrentUser" scheme="http://www.ibm.com/xmlns/prod/sn/flags"></category>
   
    
    <category term="forum-reply" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
   
    <thr:in-reply-to
        xmlns:thr="http://purl.org/syndication/thread/1.0" ref="urn:lsid:ibm.com:forum:8059f61d-921f-4fd3-afec-a730e1c482b0" href="https://greenhousestage.lotus.com/forums/atom/topics?forumUuid=8059f61d-921f-4fd3-afec-a730e1c482b0" type="application/atom+xml">
    </thr:in-reply-to>
    <content type="html">
    &lt;p dir="ltr"&gt;
      REPLY POST test
    &lt;/p&gt;
  </content>
    
</entry>
Name Type Optional Description
topicUuid
string No Uuid of the topic you wish to reply to.
Output
Content Type: application/atom+xml
Name Type Optional Description
Location
string No Link to edit_url of the forum reply. You can use the web address specified here to subsequently retrieve and update the forum reply.
Code Description
201
Created. Indicates that the forum reply was successfully created. If an error occurs, this header contains one of the error codes.
400
Bad Request.
401
Unauthorized.
Examples
> 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: 821


Response returned by the server
< 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):