Community articleCreating a stand-alone forum topic programmatically
Added by IBM contributorIBM on June 18, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

To add a topic to a stand-alone forum, send an Atom entry document containing the forum topic to the forum topics resource.


To add a topic to a stand-alone forum, send an Atom entry document containing the forum topic to the forum topics resource.

See Authenticating requests for information about how to authenticate the request.

If you want to add some tags to this topic. For each tag, add the <category term="tag name"/> element to the topic entry document that you pass in on the request.

If you want to create a question instead of a normal topic, add the <category term="question" scheme="http://www.ibm.com/xmlns/prod/sn/flags"/> element to the topic entry document that you pass in on the request.
Input
Method URI Description
POST /forums/atom/topics Value of the href attribute of the <link> element with the rel="replies" attribute value for each forum.
Content Type: application/atom+xml
Sample Request:
<entry xmlns="http://www.w3.org/2005/Atom">

	<title type="text">Test topic 1</title>

	<content type="text">topic test</content>

	<updated>2010-08-04T13:48:41.700Z</updated>

	<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="forum-topic"></category>

	<category term="aa"></category>

	<category term="bb"></category>

	</entry>

Name Type Optional Description
forumUuid
string No The UUID of the forum you wish create a topic in.
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 Forums 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
Output
Content Type: application/atom+xml
Name Type Optional Description
Location
string No Link to edit_url of the forum topic. You can use the web address specified here to subsequently retrieve and update the forum topic.
Code Description
201
Indicates that the forum topic was successfully created. If an error occurs, this header contains one of the error codes.
400
Bad Request.
401
Unauthorized.
404
No forum exists
413
Request Entity too large
415
Unsupported Media Type
Examples
POST /forums/atom/topics?forumUuid=e1b8faff-afc7-4ba8-9269-05bfd592efc7 HTTP/1.1

	Host: www.dulcinea.com

	Content-Type: application/atom+xml

	Authorization: xxx

	Content-Length: nnn

	

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

	<title type="text">Test topic 1</title>

	<content type="text">topic test</content>

	<updated>2010-08-04T13:48:41.700Z</updated>

	<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="forum-topic"></category>

	<category term="aa"></category>

	<category term="bb"></category>

	</entry>


Response returned by the server
HTTP/1.1 201 Created

	Date: Wed, 04 Aug 2010 21:45:09 GMT

	Content-Length: nnn

	Content-Type: application/atom+xml; charset="utf-8"

	Location: http://www.dulcinea.com/forums/atom/topics

	

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

	<id>urn:lsid:ibm.com:forum:84139b22-17f0-4290-939b-73370c6ef17c</id>

	<title type="text">Test topic 1</title>

	<published>2010-08-04T21:45:09.324Z</published>

	<updated>2010-08-04T21:45:09.324Z</updated>

	<author>

	<email>jdoe@literature.com</email>

	<name>Jane Doe</name>

	<snx:userid

	xmlns:snx="http://www.ibm.com/xmlns/prod/sn">772A006E-0A01-8703-8525-7346003DAFD6

	</snx:userid>

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

	</author>

	<link

	href="https://www.dulcinea.com/forums/atom/topic?topicUuid=84139b22-17f0-4290-939b-73370c6ef17c"

	rel="self"

	type="application/atom+xml">

	</link>

	<link

	href="https://www.dulcinea.com/forums/atom/topic?topicUuid=84139b22-17f0-4290-939b-73370c6ef17c"

	rel="edit"

	type="application/atom+xml">

	</link>

	<category term="forum-topic" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>

	<category term="bb"></category>

	<category term="aa"></category>

	<link

	href="https://www.dulcinea.com/forums/html/topic?id=84139b22-17f0-4290-939b-73370c6ef17c"

	rel="alternate"

	type="text/html">

	</link>

	<link

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

	href="https://www.dulcinea.com/forums/atom/replies?topicUuid=84139b22-17f0-4290-939b-73370c6ef17c"

	rel="replies"

	type="application/atom+xml"

	thr:count="0">

	</link>

	<thr:in-reply-to

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

	href="https://www.dulcinea.com/forums/atom/topics?forumUuid=e1b8faff-afc7-4ba8-9269-05bfd592efc7"

	ref="urn:lsid:ibm.com:forum:e1b8faff-afc7-4ba8-9269-05bfd592efc7"

	type="application/atom+xml">

	</thr:in-reply-to>

	<content type="html">topic test</content>

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

	none, create_forum, view_forum, edit_forum, del_forum, create_post, edit_personal_post, edit_all_post,

	del_personal_post, del_all_post, pin_topic, subscribe, lock_node, add_member, delete_member,

	create_topictag, del_all_topictag, del_personal_topictag, create_forumtag, del_all_forumtag,

	del_personal_forumtag, view_category, edit_personal_question, edit_all_question

	</snx:permissions>

	</entry>

To create a topic with an attachment, use a multipart post by completing the following steps: Send a POST request with the following content-type header: Pass the topic entry as input on the request first, and then specify the attachments. If the attachment name contains non-ASCII character, you can also use MIMIE-encoded text (defined in RFC 2047) in filename field. For example:
Content-Type: multipart/related;type="application/atom+xml"

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

	<title type="text">RE:Where do the log files go?</title>

	<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="forum-reply" />

	<thr:in-reply-to

	ref="urn:lsid:ibm.com:forum:2E8G091E0E92B0EA6D6B07051CEE7F00007C"

	type="application/atom+xml"

	href="http://www.dulcinea.com/forum/service/atom/replies?topicUuid=2E8G091E0E92B0EA6D6B07051CEE7F00007C"/>

	<content type="text">

	The log files cannot reside in the specified directory because they are too large.

	</content>

	</entry>

	--MIME_boundary 

	Content-Disposition: attachment; filename="=?UTF-8?Q?=E4=B8=AD=E6=96=87.txt?="

	(binary data of image1 file)


Response returned by the server
Note: If there are attachments in the topic entry, the metadata for the attachment will be added to the entry. For example:


<snx:field name="forum_design_images" fid="4b59fea6-2810-42ef-ae4a-37334674e138" type="file">

	<link

	type="image/jpg"

	href="http://www.dulcinea.com/forums/atom/download?nodeId=4b59fea6-2810-42ef-ae4a-37334674e138" length="2020" />

	</snx:field>