Create communities programmatically
To create a community, send an Atom entry document containing the new community to the My Communities resource.See Authenticating requests for information about how to authenticate the request.
Table 1. Atom API request details
Method Resource URI Input representation POST User's My communities feed Value of the href attribute of <collection> element in the Communities Collections workspace with a child <title> that has the value My Communities. community
Input
Provide a community Atom entry document.Note: The content type of the Atom entry document must be application/atom+xml.
Output
None.Returned HTTP headers
HTTP/1.1 201 Created
Indicates that the community was successfully created. If an error occurs, this header contains one of the error codes.
Location: url
Link to edit_url of the new community entry. You can use the web address specified here to subsequently retrieve and update the community entry.
- HTTP/1.1 400 Bad Request
- HTTP/1.1 401 Unauthorized
- HTTP/1.1 409 Conflict: Another publicly viewable community has the same name.
Example
Request:
> POST /communities/service/atom/communities/my HTTP/1.1> Authorization: Basic xxx > Host: enterprise.example.com > Accept: */* > Content-Type: application/atom+xml > Content-Length: 920Content of the MyCommunities.xml file:
<?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">Day Care Community</title> <summary type="text">ignored</summary> <content type="html">Share information about day care.</content> <published>ignored</published> <author> <name>John Jordan</name> <email>jjordan@example.com</email> <snx:userid>50730340-0101-102e-88e1-f78755f7e0ed</snx:userid> <snx:userState>active</snx:userState> </author> <updated>ignored</updated> <contributor> <name>John Jordan</name> <email>jjordan@example.com</email> <snx:userid>50730340-0101-102e-88e1-f78755f7e0ed</snx:userid> <snx:userState>active</snx:userState> </contributor> <category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category> <snx:membercount>ignored</snx:membercount> <snx:communityType>public</snx:communityType> </entry>Response:
< HTTP/1.1 201 Created< Date: Tue, 10 Aug 2010 20:59:51 GMT < Server: IBM_HTTP_Server < Expires: Thu, 1 Jan 1970 00:00:00 GMT < Cache-Control: no-store, no-cache, must-revalidate < X-LConn-Auth: false < X-UA-Compatible: IE=EmulateIE7 < Last-Modified: Tue, 10 Aug 2010 20:59:51 GMT < Location: https://enterprise.example.com/communities/service/atom/communi ty/instance?communityUuid=35d34540-f36d-4aac-bcd0-9c76c41fe8ee < Set-Cookie: xxx < Set-Cookie: xxx < Set-Cookie: xxx < Content-Length: 0 < Content-Type: text/html < Content-Language: en-US < * Connection #0 to host enterprise.example.com left intact * Closing connection #0 * SSLv3, TLS alert, Client hello (1):
Parent topic
Work with communities programmaticallyRelated reference
Community entry content